[Grok-dev] How do I look up a grok.Indexes utility so I can call methods on an index?
Sebastian Ware
sebastian at urbantalk.se
Wed Aug 25 09:35:17 EDT 2010
That is the route I have been trying, but I am at a loss as to what interface to look up the catalog with. I can't find what grok.Indexes implements. I have been trying different versions of:
getUtility( ???, 'content_index')
Mvh Sebastian
25 aug 2010 kl. 15.18 skrev Souheil CHELFOUH:
> the index is in the catalog itself.
> get the catalog, the stored values are the indexes which, themselves,
> store the values needed for the indexation.
>
>
> 2010/8/25 Sebastian Ware <sebastian at urbantalk.se>:
>> I have a value index from zc.catalog and I want to use the implemented sort method. However, I don't understand how to look up the actual index. The index is defined as:
>>
>> class SitePublishCatalog(grok.Indexes):
>> grok.site(Testvalueindex)
>> grok.context(IPublished)
>> grok.name('content_index')
>>
>> published = Value()
>>
>> I want to be able to do call index.sort(res) on my results that come from hurry.query, in the way explained in the zc.catalog doctest.
>>
>> """
>> Sorting
>> -------
>>
>> Value indexes supports sorting, just like zope.index.field.FieldIndex.
>>
>> >>> index.clear()
>>
>> >>> index.index_doc(1, 9)
>> >>> index.index_doc(2, 8)
>> >>> index.index_doc(3, 7)
>> >>> index.index_doc(4, 6)
>> >>> index.index_doc(5, 5)
>> >>> index.index_doc(6, 4)
>> >>> index.index_doc(7, 3)
>> >>> index.index_doc(8, 2)
>> >>> index.index_doc(9, 1)
>>
>> >>> list(index.sort([4, 2, 9, 7, 3, 1, 5]))
>> [9, 7, 5, 4, 3, 2, 1]
>> """
>>
>> Mvh Sebastian
>>
>>
>>
>> _______________________________________________
>> Grok-dev mailing list
>> Grok-dev at zope.org
>> https://mail.zope.org/mailman/listinfo/grok-dev
>>
More information about the Grok-dev
mailing list