[ZODB-Dev] zope.generations to standalone ZODB ?

Marius Gedminas marius at gedmin.as
Mon Aug 27 18:01:06 UTC 2012


On Mon, Aug 27, 2012 at 11:57:25PM +1200, Richard Shea wrote:
> Hi - I've been looking at zope.generations
> (http://pypi.python.org/pypi/zope.generations) - "Generations are a way
> of updating objects in the database when the application schema
> changes".
> 
> My interest is for a standalone ZODB database. The example given on that
> page seems to presume that generations will only ever be used within
> Zope. It's a shame because it looks like a good facility.

I'm too tired to read that page and see where it creates that (false)
impression.

> My questions are : 
> 
>    * Is zope.generations able to be used on a standalone ZODB database ?

Yes.  All you need to do is make sure the event subscriber is invoked
when you open the database.  In other words, once you open a DB
connection, zope.event.notify(DatabaseOpenedEvent(...)), or at the very
least invoke the evolveMinimumSubscriber() by hand.

>    * Are there other, similar, facilities which would track change to
>    application classes (or at least accept notifications of them) and
>    automatically 'fixup' the corresponding classes already in the
>    database ?

I wouldn't call zope.generations automatic.  You have to write evolution
scripts by hand.  Also, you have to understand ZODB really really well
(e.g. avoid certain kinds of changes that are impossible to support even
with zope.generations, like renaming classes or modules, etc.).

In my experience writing evolution scripts is a big pain, so I avoid
that where possible using various tricks:

  - class attributes with sensible default values for all newly-added
    attributes
  - autovivification via __getattr__ or properties (e.g.
    zope.cachedescriptors.property.Lazy)

Marius Gedminas
-- 
5. Is RetchMail standards-compliant?

Quick answer: HA HA HA HA HA HA no.
	-- http://alumnit.ca/wiki/index.php?page=RetchMail
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 190 bytes
Desc: Digital signature
URL: <http://mail.zope.org/pipermail/zodb-dev/attachments/20120827/d8dff408/attachment.sig>


More information about the ZODB-Dev mailing list