[Grok-dev] Re: Newbie search tutorial

Sebastian Ware 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.

Mvh Sebastian

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:
>
> http://svn.zope.org/Sandbox/luciano/kirbi/src/kirbi/pac.py? 
> rev=77634&view=markup
> or
> http://tinyurl.com/yox8pw
>
> 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 [2], which
> may be very significant in the use case.
>
> http://www.python.org/dev/peps/pep-0290/
>
> If you agree, I will make the needed changes.
>
> Cheers,
>
> Luciano
> _______________________________________________
> Grok-dev mailing list
> Grok-dev at zope.org
> http://mail.zope.org/mailman/listinfo/grok-dev



More information about the Grok-dev mailing list