1
# -*- axiom.test.test_upgrading -*-
4
def registerUpgrader(upgrader, typeName, oldVersion, newVersion):
6
Register a callable which can perform a schema upgrade between two
9
@param upgrader: A one-argument callable which will upgrade an object. It
10
is invoked with an instance of the old version of the object.
11
@param typeName: The database typename for which this is an upgrader.
12
@param oldVersion: The version from which this will upgrade.
13
@param newVersion: The version tow hich this will upgrade. This must be
14
exactly one greater than C{oldVersion}.
16
# assert (typeName, oldVersion, newVersion) not in _upgradeRegistry, "duplicate upgrader"
18
# ^ this makes the tests blow up so it's just disabled for now; perhaps we
19
# should have a specific test mode
20
assert newVersion - oldVersion == 1, "read the doc string"
21
_upgradeRegistry[typeName, oldVersion, newVersion] = upgrader
23
def upgradeAllTheWay(o, typeName, version):
26
upgrader = _upgradeRegistry[typeName, version, version + 1]