[Zope] Object reference and the _SetObject() method
Johan Carlsson
johanc@torped.se
Tue, 19 Oct 1999 11:50:14 +0200
> > My questions!
> >
> > Is this correct to do this or can I get my self
> > in trouble doing direct reference in this way?
> You will eventually ;-) Especially if your objects are not Zope objects
> that follow the Zope management interface.
But what could happen, if I keep record of the references, where could
it break? And yes I'm going the link only objects with Management Interface.
Here's what I whan to do:
I want to create superclasses for bidirectional links between Zope
objects. The link object has a object _link thats a object referense
to the other object. The other objects has a list of links to it
so when it's deleted it can notify the link object. Have been looking
in ObjectManager if one can use the manage_beforedelete method
to handle the delete through a tree.
>
> > And what does the _p_changed.
>
> setting _p_changed notifies ZODB that the relevant object has changed
> status and takes the neccessary steps to save it etc. You might need it in
> situations where changes to the object are not registered automatically by
> ZODB. For instance, lets suppose your object has a mutable attribute
> mylist, then:
>
>
> self.mylist.append(1)
>
> will not be registered by the ZODB, whereas:
> tmp=self.mylist
> tmp.append(1)
> self.mylist=tmp
>
> will be registered as ZODB intercepts the __getattr__ call.
>
> In the former case you will need to set _p_changed manually.
I new this, but I had forgoten it.
Thanks for reminding me Pavlos ;-)
Johan Carlsson