[Zope-dev] Re: Zope and Storm (SQL)
Martijn Faassen
faassen at startifact.com
Mon May 26 11:22:28 EDT 2008
Hi there,
David Pratt wrote:
[snip]
> For me, the crux of the rdb approach for legacy code is the container,
> location and traversal. You have been very generous with your examples.
> I am really hoping for a clearer idea of handling Container,
> OrderedContainer, and Location which is prevalent in legacy code.
> Overall, I can say that I quite the innovation here in getting to a
> 'leaner' concept of Zope.
I myself wouldn't be inclined to call Container and Location only
relevant to legacy code.
It's very convenient to have a RDB-backed object have a location, as
that allows you to get the URL for it in the regular manner.
For Container, in the megrok.rdb prototype code we actually make
containers be SQLAlchemy 'MappedCollection' objects. MappedCollection
happens to implement the container API already. This way we can make
relations be containers by writing something like:
class Departments(rdb.Container):
# this is a MappedCollection
rdb.key('title')
class Faculty(rdb.Model):
# rdb.table_name('faculty') is the default
__tablename__ = 'faculty'
grok.traversable('departments')
departments = relation('Department',
backref='faculty',
collection_class=Departments)
The 'departments' attribute is a container you can traverse into this
way. You can hook up views to Departments just like you would to any
container.
Regards,
Martijn
More information about the Zope-Dev
mailing list