Internal reference between objects saved in ZODB gets lost?
If I create two objects and saves them with 'setObject' any references between objects is lost. Is that true? Simple stoopid non-working code example:: class test: def __init__(self, id, otherObject=None): self.id = id self.otherObject= otherObject class table(ObjectManager): def __init__(self): object1 = test('1') object2 = test('2', object1) self._setObject('1') self._setObject('2', object2) Do I have to save a reference to another persistent object as an objectManager id instead? Like this: class test: def __init__(self, id, otherObject=None): self.id = id self.otherObject= otherObject class table(ObjectManager): def __init__(self): object1 = test('1') object2 = test('2', '1') self._setObject('1') self._setObject('2', object2) Saving the reference directly is so much easier. But apparantly I get into trouble when I try to. I could save all my data structure in a dict or somesuch structure. This keeps the references intact. But I guess that i will get a nasty growth in Data.fs whenever the object is changed. At least until a packing of the database. Something like:: number of objects * size pr object * times changed This could probebly be a real problem if the object had a size of 500 MBs in all and lots of changes. Do I understand this correctly? regards Max M Max M. W. Rasmussen, Denmark. New Media Director private: maxmcorp@worldonline.dk work: maxm@normik.dk ----------------------------------------------------- Shipping software is an unnatural act
Max M writes:
If I create two objects and saves them with 'setObject' any references between objects is lost. Is that true?
Simple stoopid non-working code example::
class test: def __init__(self, id, otherObject=None): self.id = id self.otherObject= otherObject
class table(ObjectManager):
def __init__(self): object1 = test('1') object2 = test('2', object1) self._setObject('1') self._setObject('2', object2) The "self._setObject('1')" looks a bit strange (no "object" parameter), but otherwise, it should work (I think).
Maybe, it helps when you derive "test" from "Persistent". Dieter
participants (2)
-
Dieter Maurer -
Max M