[ZODB-Dev] newbie to zodb

Christian Robottom Reis kiko at async.com.br
Thu Jul 1 20:34:19 EDT 2004


On Thu, Jul 01, 2004 at 02:19:23PM -0400, Joao Paulo Liberato wrote:
> AFAIK, Zope3 has its own Data.fs, and therefore it uses zodb.  Hence, 
> how do I make my own classes persistent?  I subclass
> persistent.Persistent, but what I do next?  How can I store and
> retrieve instances of that class?

Well, in a very high level, you need to reference your classes from
other persistent objects already linked to the database root. ZODB
persists by reachability -- IOW, if there is a graph of references
[through persistent objects] between the database root and your
instance, its state will be stored.

Organizing your instances under the root, however, is up to you. This is
often confusing to someone starting off with the ZODB: while a RDBMS
provides a structure (and indexing and query mechanisms) for your data,
the ZODB provides only a persistence service, and you decide how you
want to organize your data. There are however some patterns that are
normally used; for instance, storing your object hierarchies under a
string key/keys in the root dictionary, and using BTrees to store large
collections of instances.

Take care,
--
Christian Robottom Reis | http://async.com.br/~kiko/ | [+55 16] 3361 2331


More information about the ZODB-Dev mailing list