You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@bloodhound.apache.org by Antonia Horincar <an...@gmail.com> on 2014/06/11 01:46:29 UTC

[GSoC COMDEV-108] Getting resources attributes

Hi,

Is there a way to retrieve all the attributes of a BH resource? For example, I am working on storing tickets in the Solr index, and I need to create a dictionary mapping each ticket field type to its value. However, when fetching tickets from the database, they are returned as tuples. I tried to get the attributes by using the get_ticket_fields method in the trac.ticket.api module, but I get the error: "RuntimeError: maximum recursion depth exceeded while calling a Python object”. Apparently, the program fails at the step where it deepcopies the fields (fields = copy.deepcopy(ts.fields)). Has anyone encountered this error before?

Thanks,
Antonia

Re: [GSoC COMDEV-108] Getting resources attributes

Posted by Anže Starič <an...@gmail.com>.
Whoosh differentiates between "search by" and "display" values of the
fields. By default, the same value is used for both cases, but when
one needs to display different value (we allow searching for ticket
id-s using ID and #ID syntax, but only show ID), one can add
_stored_FIELDNAME to dict, and that value will be use when FIELDNAME
is returned in document.


Anze

On Thu, Jun 12, 2014 at 9:15 PM, Antonia Horincar
<an...@gmail.com> wrote:
> Thank you for the info. I have no idea why it works on server either.
>
> My question now is regarding a ticket field created for indexing in Whoosh. TicketIndexer has the method build_doc(trac_doc), which at one point creates the field ‘_stored_name’, and assigns the ticket id as its value. What is the role of this field? Because it isn’t specified in the Whoosh schema (and neither in IndexFields and TicketFields).
>
> Thanks,
> Antonia
>
> On 12 June 2014 at 09:15:47, Anže Starič (anze.staric@gmail.com) wrote:
>
> I have no idea why it works when it is run on server, but the infinite
> recursion looks like a Babel problem. It is caused by deepcopy-ing a
> LazyProxy object. I have managed to work around it by modifying
> LazyProxy object in Babel [1].
>
>
> Anze
>
> [1] https://github.com/astaric/babel/commit/53b38bfc7c06bb20d88897946affc9f28344db9f
>
> On Thu, Jun 12, 2014 at 3:12 AM, Antonia Horincar
> <an...@gmail.com> wrote:
>> Thanks a lot for your help. TicketIndexer is really helpful for my issue. I noticed than I can’t initialise TicketIndexer in the Python interpreter (due to the same runtime error I mentioned earlier), but I can test it when running it on the server (through match_request and process_request), so that’s not a problem for now.
>>
>> Antonia

Re: [GSoC COMDEV-108] Getting resources attributes

Posted by Antonia Horincar <an...@gmail.com>.
Thank you for the info. I have no idea why it works on server either.

My question now is regarding a ticket field created for indexing in Whoosh. TicketIndexer has the method build_doc(trac_doc), which at one point creates the field ‘_stored_name’, and assigns the ticket id as its value. What is the role of this field? Because it isn’t specified in the Whoosh schema (and neither in IndexFields and TicketFields).

Thanks,
Antonia

On 12 June 2014 at 09:15:47, Anže Starič (anze.staric@gmail.com) wrote:

I have no idea why it works when it is run on server, but the infinite  
recursion looks like a Babel problem. It is caused by deepcopy-ing a  
LazyProxy object. I have managed to work around it by modifying  
LazyProxy object in Babel [1].  


Anze  

[1] https://github.com/astaric/babel/commit/53b38bfc7c06bb20d88897946affc9f28344db9f  

On Thu, Jun 12, 2014 at 3:12 AM, Antonia Horincar  
<an...@gmail.com> wrote:  
> Thanks a lot for your help. TicketIndexer is really helpful for my issue. I noticed than I can’t initialise TicketIndexer in the Python interpreter (due to the same runtime error I mentioned earlier), but I can test it when running it on the server (through match_request and process_request), so that’s not a problem for now.  
>  
> Antonia  

Re: [GSoC COMDEV-108] Getting resources attributes

Posted by Anže Starič <an...@gmail.com>.
I have no idea why it works when it is run on server, but the infinite
recursion looks like a Babel problem. It is caused by deepcopy-ing a
LazyProxy object. I have managed to work around it by modifying
LazyProxy object in Babel [1].


Anze

[1] https://github.com/astaric/babel/commit/53b38bfc7c06bb20d88897946affc9f28344db9f

On Thu, Jun 12, 2014 at 3:12 AM, Antonia Horincar
<an...@gmail.com> wrote:
> Thanks a lot for your help. TicketIndexer is really helpful for my issue. I noticed than I can’t initialise TicketIndexer in the Python interpreter (due to the same runtime error I mentioned earlier), but I can test it when running it on the server (through match_request and process_request), so that’s not a problem for now.
>
> Antonia

Re: [GSoC COMDEV-108] Getting resources attributes

Posted by Antonia Horincar <an...@gmail.com>.
Thanks a lot for your help. TicketIndexer is really helpful for my issue. I noticed than I can’t initialise TicketIndexer in the Python interpreter (due to the same runtime error I mentioned earlier), but I can test it when running it on the server (through match_request and process_request), so that’s not a problem for now.

Antonia

On 11 June 2014 at 07:41:42, Anže Starič (anze.staric@gmail.com) wrote:

On Wed, Jun 11, 2014 at 1:46 AM, Antonia Horincar  
<an...@gmail.com> wrote:  
> Hi,  
>  
> Is there a way to retrieve all the attributes of a BH resource? For example, I am working on storing tickets in the Solr index, and I need to create a dictionary mapping each ticket field type to its value.  

This sounds similar to what TicketIndexer [1] does. It converts  
tickets to dictionaries mapping field names to their values.  

If your Solr search implements ISearchBackend [2], its add_doc method  
will get the dict created by TicketIndexer and you don't have to do  
the conversion yourself.  

Anze  

[1] https://github.com/apache/bloodhound/blob/trunk/bloodhound_search/bhsearch/search_resources/ticket_search.py#L45  
[2] https://github.com/apache/bloodhound/blob/trunk/bloodhound_search/bhsearch/api.py#L94  

Re: [GSoC COMDEV-108] Getting resources attributes

Posted by Anže Starič <an...@gmail.com>.
On Wed, Jun 11, 2014 at 1:46 AM, Antonia Horincar
<an...@gmail.com> wrote:
> Hi,
>
> Is there a way to retrieve all the attributes of a BH resource? For example, I am working on storing tickets in the Solr index, and I need to create a dictionary mapping each ticket field type to its value.

This sounds similar to what TicketIndexer [1] does. It converts
tickets to dictionaries mapping field names to their values.

If your Solr search implements ISearchBackend [2], its add_doc method
will get the dict created by TicketIndexer and you don't have to do
the conversion yourself.

Anze

[1] https://github.com/apache/bloodhound/blob/trunk/bloodhound_search/bhsearch/search_resources/ticket_search.py#L45
[2] https://github.com/apache/bloodhound/blob/trunk/bloodhound_search/bhsearch/api.py#L94