The ZoDB is an object database which transparently makes any changes to objects in memory persist between sessions and between individual runs of your application.  A ZoDB object literally looks like any other object except that any changes made to it are long lived.  To accomplish this magic, one must follow a couple of rules.

Conditions for persistent objects

In order for a Zope (ZoDB) object to be persitent, it must fulfill the following conditions:

  • It must be pickleable
  • It must not have any normal attributes starting with a _p_
  • Attributes starting with a _v_ are not persisted (volatile)
  • Any changes to mutable attributes such as dicts or lists must be flagged by setting the _p_changed attribute to True.
  • A persistent class cannot have a __del__() method
  • Persistent classes derive from Persistence.Persistent.

Other databases

In the case where a relational database or alternative store is used for permanent storage, different rules will apply for marshalling or instantiating objects from the database.

Grok 4 Noobs

Rules of Persistence