__parent__ - like attribute?

Andrew Bennetts andrew-pythonlist at puzzling.org
Sun Jan 19 04:48:28 CET 2003


On Sat, Jan 18, 2003 at 05:23:45PM -0800, Dylan Reinhardt wrote:
> Seems like this should be easy, but I'm having a tough time figuring out 
> how to change an attribute in a parent object *as a side effect* of a 
> method called on a subobject.
> 
> An quick example:
[..snip..]
> 
> If this looks like manipulation of the _p_changed attribute in ZODB, it's 
> not a coincidence... that's what I'm hoping to use this for.  I realize I 
> could pull a reference to a from globals() assuming I know the parent class 
> is called "a" or "b", but I'm hoping there's a way to go about this without 
> storing the parent name in every sub-object.

If I'm understanding you correctly, you have a "spam" instance, which
contains an "eggs" instance, and you want changes to the eggs instance to
persisted.  

Why don't you simply make eggs inherit from Persistent, and let it set its
own _p_changed flag?

-Andrew.






More information about the Python-list mailing list