[ZODB-Dev] Referential integrity

Magnus Lyckå magnus@thinkware.se
Sat, 02 Mar 2002 00:46:30 +0100


At 17:47 2002-03-01 -0500, Mike Fletcher wrote:
>I actually had to deal with referential integrity problems in an app just=
 
>two weeks ago.  Best approach I found was to wire in a watcher that looks=
 
>for ObjectDeleted events on the collection, and on finding one, does the 
>scan explicitly.  Similarly, the property classes for the objects refresh=
 
>conflict sub-tables and check object consistency as soon as an attribute 
>is altered.

Huh? How do you do that? I'm just thinking about a
similar case in my app. (But here the problem is probably
more a matter of finding all the places where I might have
a link to this object. There's no magical "who references
me" function in Python or ZODB, is there?)

I've thought about different concepts like:

a = SomeKindOfObject()
b = SomeKindOfObject()
a.addChild(b)

class SomeKindOfObject(...):
     ...
     def addChild(self, other):
         # Double linked relation
         self.__children.append(other)
         other.__parents.append(self)

or:

     def addChild(self, other):
         # Separate "link table"
         getParentChild.add(self, other)

But if I could simply do:

     def addChild(self, other):
         self.__children.append(other)

and "magically" be able to find a from b without
traversing all my objects, well, then that would
be very convenient...

/Magnus



-- 
Magnus Lyckå, Thinkware AB
Älvans väg 99, SE-907 50 UMEÅ
tel: 070-582 80 65, fax: 070-612 80 65
http://www.thinkware.se/  mailto:magnus@thinkware.se