[Grok-dev] Re: grok and the ORM of your choice

Philipp von Weitershausen philipp at weitershausen.de
Fri Jul 20 05:24:48 EDT 2007


Tim Penhey wrote:
> I'd like to use grok with storm, but I feel that the process would be fairly
> similar no matter which ORM you are using.
> 
> My problem is getting started.  If someone can point me in the right direction,
> I'd be happy to trundle down and write stuff up and contribute to grok, but
> it is the initial direction that I am flailing with.
> 
> So firstly I'd need to be able to map '/' to some view, or to be able to map
> +some-view to something, and be able to set a default view for '/'.
> 
> Then I need to be able to define traversal, say /foo to some (plain) python object,
> and it could then take the next item from the traversal stack, say 'bar', and use
> that to search for an object, and be able to define views for peristant objects
> (ORM persisted, not ZODB persisted).

The typical way to go is that you create an object that serves as a 
"window" into the ORM world. This window itself is ZODB-persisted, but 
it only ever refers to ORM objects.

A natural data structure for this in Zope would be a container. Another 
possibility, as you mention, would be to use custom traversal, e.g.::

   class MyORMApp(grok.Application, grok.Model):

       def traverse(self, name):
           return find_object_from_sql_database_by_name(name)


-- 
http://worldcookery.com -- Professional Zope documentation and training


More information about the Grok-dev mailing list