[Zope3-Users] Containers and ZODB

Christophe Combelles ccomb at free.fr
Fri Aug 24 15:36:40 EDT 2007


Drew Smathers a écrit :
> I'm new to zope3 and have been writing an application backed by a
> relational database.  I wanted to created a IContainer implementation
> which essential provides a view of items in the database, but there is
> no need for to make the container instances manageable through the ZMI
> or persistent in either ZODB or through the ORM layer (incidentally,
> I'm using Storm).
> 
> To paraphase how the application works, I have something like:
> 
> class FooBarContainer(MyContainerImplementation):
>   containedQuery = "select * from foobars"
> 
> The implementation is slightly more complex, but really doesn't
> matter.  I just want the container to exist at runtime, without any
> knowledge of it in ZODB.  Nor do I want someone to have to explicitly
> add containers through the ZMI, since the containers I'm defining are
> inherently part of the application.  Does anyone have any suggestions
> on a good way to achieve this?
> 

You don't really need to implement a container, you could just write a non 
persistent object (not derived from Persistent), and create a view on it.
But the next problem is to be able to traverse to this object, since traversal 
starts from the root of the zodb.

My advice would be to use a simple persistent object and store some stuffs in it 
(sql query?), so you can easily traverse to it and to its view.

Christophe


More information about the Zope3-users mailing list