[PEAK] Cascading delete

Tiago Cogumbreiro cogumbreiro at gmail.com
Thu Jul 21 16:41:35 EDT 2005


Hi again list,

My data managers support a "delete-oids" event, where its listeners
can know when and which oids are removed from a given DM.

Is it a good policy to use the '_remove_oids' to propagate the removal
of oids directly?

My problem is: I have a DM that contains entries from a "foreign" DM
which I do not know its implementation and don't want to do a:
----
for oid in oids:
    obj = self.get (oid)
    self.ForeignDM.remove (obj.bar)
    obj.bar = None
----

It would be easier to call:
----
# possibly a "SELECT Foreign_id WHERE ..."
foreign_oids = self.getForeignObjectOids (oids) 

if hasattr (self.ForeignDM, "_remove_oids"):
    self.ForeignDM._remove_oids (oids)
else:
    # good old iteration for removal
    for oid in oids:
        obj = self.get (oid)
        self.ForeignDM.remove (obj.bar)
        obj.bar = None
----

If this is the case, should I use an adaptation technique? I really
haven't got into "adaptation patterns". The "hasattr" is really making
me remember a quote from PyProtocol.



More information about the PEAK mailing list