Schema manager

Schema managers implement IInstallableSchemaManager using scripts provided as module methods. You create a schema manager by providing mimumum and maximum generations and a package providing modules named evolveN, where N is a generation number. Each module provides a function, evolve that evolves a database from the previous generation.

For the sake of the example, we'll use the demo package defined in here. See the modules there for simple examples of evolution scripts.

So, if we'll create a SchemaManager:

>>> manager = SchemaManager(1, 3, '')

and we'll create a test database and context:

>>> from ZODB.tests.util import DB
>>> db = DB()
>>> context = Context()
>>> context.connection =

Then we'll evolve the database from generation 1 to 3:

>>> manager.evolve(context, 2)
>>> manager.evolve(context, 3)
>>> transaction.commit()

The demo evolvers simply record their data in a root key:

>>> from import key
>>> conn =
>>> conn.root()[key]
(2, 3)

You can get the information for each evolver by specifying the destination generation of the evolver as argument to the getInfo() method:

>>> manager.getInfo(1)
'Evolver 1'
>>> manager.getInfo(2)
'Evolver 2'
>>> manager.getInfo(3) is None

If a package provides an install script, then it will be called when the manager's intall method is called:

>>> conn.sync()
>>> del conn.root()[key]
>>> transaction.commit()
>>> conn.root().get(key)
>>> manager.install(context)
>>> transaction.commit()
>>> conn.sync()
>>> conn.root()[key]

If there is not install script, the manager will do nothing on an install:

>>> manager = SchemaManager(1, 3, '')
>>> manager.install(context)

We handle ImportErrors within the script specially, so they get promoted:

>>> manager = SchemaManager(1, 3, '')
>>> manager.install(context)
Traceback (most recent call last):
ImportError: No module named nonexistingmodule

We'd better clean up:

>>> context.connection.close()
>>> conn.close()
>>> db.close()

Base classes

Implemented Interfaces


There are no attributes in this class.


Known Subclasses

There are no known subclasses.