[Zope-dev] Re: __setattr__ and acquisition ( was RE: __getattr__ and acquisition)

Casey Duncan casey@zope.com
05 Jun 2002 10:06:17 -0400


AFAIK acquisition bows out quietly during __getattr__, __setattr__.
You'll have to find another way to pass in the "thing" values before
__setattr__ gets called.

Maybe try an explicit self.aq_acquire('thing'). Maybe that would work.

-Casey

On Wed, 2002-06-05 at 09:33, Nicholas Henke wrote:
> Given the following code:
>  I can see why access to self.thing fails in Inner::__setattr__, but the 
> question is how do I do that -- can I not use __setattr__ and have to use a 
> setAttr that is accessed via O.I.setAttr('help','me rhonda') ?
> 
> Nic
> 
> import ExtensionClass, Acquisition
> 
> class Outer(ExtensionClass.Base):
> 	thing = ('help','donthelp')
> 
> class Inner(Acquisition.Implicit):
> 	def __setattr__(self,name,value):
> 		if name in self.thing:
> 			self.__dict__['name'] = value
> 		else:
> 			print "Bad attribute"
> 			
> O = Outer()
> I = Inner()
> O.I = I
> print O.I.thing  # is ok  --> gives ('help','donthelp')
> O.I.help = 'me rhonda' # AttributeError: thing
> 
> 
>