= How to upgrade to Dejavu 1.4 = == Recalling == Changeset [85] saw a change for sandbox.recall: it used to return an iterator, now it returns a list. Use xrecall now if you want an iterator. Multirecall is gone now. It used to take arguments in {{{(cls, expr)}}} pairs (until [110]); it's now been folded into {{{recall(classes, expr)}}} (in [120]). The 'classes' arg can be a single Unit class (as before) or a new UnitJoin class. The 'expr' arg can now handle multiple classes itself. See the "modeling" documentation for complete details. == Triggers == Changeset [71] got rid of UnitProperty.pre and .post (previously, triggers were implemented by overriding them). Now, you should override {{{UnitProperty.__set__}}} instead. == Associations == The Unit association architecture changed dramatically in changeset [101], from using factory functions to using non-data descriptors. Therefore: {{{ #!html
>>> class Country(dejavu.Unit):
... pass
...
>>> class City(dejavu.Unit):
... CountryID = dejavu.UnitProperty(int)
...
>>> Country.one_to_many('ID', City, 'CountryID')
...make some Countries and Cities...
>>> Paris.Country()
<__main__.Country object at 0x008A6D70>
>>> France.City()
[<__main__.City object at 0x008A6D10>, <__main__.City object at 0x008A6C90>]
>>>
dejavu.associate(cls1, key1, cls2, key2) is gone. Instead, call cls1.associate(key1, cls2, key2).class Person(Unit):
MotherID = UnitProperty(int, index=True)
Mother = ToOne('MotherID', Person, 'ID')
{cls, (key, farKey)}. Now, it is of the form {cls.__name__, UnitAssociation()}. To access the far classes, get each UnitAssociation.farClass.unit.first(cls2, **kw) method is gone; it was used mostly for *-to-one relations. If you still need to obtain the first unit from a *-to-many relation, call sandbox.unit(cls2, farID=unit.nearID, **kw) (or recall(cls2, expr)[0] or unit.otherClassName()[0] or xrecall(cls2, expr).next()).