[PEAK] Re: Cascading delete
Tiago Cogumbreiro
cogumbreiro at gmail.com
Thu Jul 21 17:05:58 EDT 2005
Of course I meant "_delete_oids" instead of the non-existant
"_remove_oids" method.
On 7/21/05, Tiago Cogumbreiro <cogumbreiro at gmail.com> wrote:
> 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.
>
--
Tiago Cogumbreiro <cogumbreiro at users.sf.net>
http://s1x.homelinux.net/
More information about the PEAK
mailing list