[Grok-dev] New Grok user with some questions

Kevin Teague kevin at bud.ca
Tue Jun 24 22:42:49 EDT 2008


>
> - I found some references about local utilities but no real  
> documentation about it. Is there some documentation or sample code  
> on how to use local utilities in Grok?
>

There is a small mention in the Official Grok Reference, but the  
reference isn't finsihed and published on the web site yet:

http://svn.zope.org/grok/trunk/doc/reference/components.rst?rev=82908&view=markup

In the absence of documentation, the ftests and tests directories in  
the grok source package make for reasonable examples of how to do  
things. But asking questions on the list is also good, since it has a  
chance of prodding someone into documentating something :)


> - One of my main problems with ZODB is how to implement m:n  
> relations. I think most people comming from relational databases  
> have this problem and a short how-to would be quite helpfull.  
> Perhaps this would be a nice lighting talk on the Europython 2008? ;-)
>

lovely.relation (http://svn.zope.org/lovely.relation/) is AFAIK the  
best place to start for modeling many to many relationships (um, M:N  
to is many-to-many)? It's a Zope 3 package built on the lower level  
zc.relationship package. I've only gone far enough with this package  
to create a very simple relationship in Grok 0.12, but maybe once I've  
used it a bit more I'll write up a how-to - there is a fair bit of  
docs within the package itself as well. I set-up the necessary local  
utilites in my Grok app for this package with something like:

from zope.app.intid.interfaces import IIntIds
from zope.app.intid import IntIds
from lovely.relation.app import O2OStringTypeRelationships
from lovely.relation.interfaces import IO2OStringTypeRelationships

class TripBagger(grok.Application, grok.Container):
     grok.local_utility(IntIds, IIntIds)
     grok.local_utility(O2OStringTypeRelationships,  
IO2OStringTypeRelationships)





More information about the Grok-dev mailing list