[Zope-dev] __setattr__ and acquisition

Nicholas Henke henken@unholymess.com
Sat, 1 Jun 2002 14:22:02 -0400


ok -- this has to be a stupid question that I should have RTFM somewhere =
--=20
but I couldn't find the FM for the life of me. Given the following code, =
I=20
can see why access to self.thing fails in Inner::__setattr__, but the=20
question is how do I do that -- can I not use __setattr__ and have to use=
 a=20
setAttr that is accessed via O.I.setAttr('help','me rhonda') ?

Nic

import ExtensionClass, Acquisition

class Outer(ExtensionClass.Base):
=09thing =3D ('help','donthelp')

class Inner(Acquisition.Implicit):
=09def __setattr__(self,name,value):
=09=09if name in self.thing:
=09=09=09self.__dict__['name'] =3D value
=09=09else:
=09=09=09print "Bad attribute"
=09=09=09
O =3D Outer()
I =3D Inner()
O.I =3D I
print O.I.thing  # is ok  --> gives ('help','donthelp')
O.I.help =3D 'me rhonda' # AttributeError: thing