[Grok-dev] Re: Newbie search tutorial
sebastian at urbantalk.se
Mon Jul 9 02:46:29 EDT 2007
Sounds like a no brainer to me. I think you should go ahead.
Sorting and batching are two basic activities that one is used too
from Zope 2.
9 jul 2007 kl. 02.02 skrev Luciano Ramalho:
> I've reviewed and used the search minitutorial (thanks, Sebastian!)
> and I'd like to suggest a few changes:
> - Since hurry.query is not a dependency of Zope or Grok, I think the
> tutorial should explain how to searches without it, and then perhaps
> in a last section introduce hurry.query and show its benefits.
> - There are two blanks which I think newbies would like to see filled:
> 1) show how the search is actually invoked. In Kirbi I did it in the
> view update method, setting a view attribute called results:
> 2) show how to sort the results, since people coming from Zope 2 or an
> SQL-based framework will expect the catalog to do it for them.
> This is the sorting code I'd like to include as an example:
> class Index(grok.View):
> def update(self, query=None):
> if not query: self.results = 
> results = list(catalog.searchResults(title=query))
> self.results = sorted(results, key=attrgetter('title'))
> The attrgetter call can be replaced by lambda x:x.title but PEP-290
> claims the attrgetter function in module operator is faster , which
> may be very significant in the use case.
> If you agree, I will make the needed changes.
> Grok-dev mailing list
> Grok-dev at zope.org
More information about the Grok-dev