[Zope-dev] __setattr__ and acquisition ( was RE: __getattr__ and acquisition)
Nicholas Henke
henken@unholymess.com
Wed, 5 Jun 2002 09:33:02 -0400
Given the following code:
I 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