[Zope3-Users] Infinite recursion when storing FieldProperties in as annotations (using IAttributeAnnotations).

Alec Munro alecmunro at gmail.com
Mon Aug 29 11:26:32 EDT 2005


On 8/29/05, Stephan Richter <srichter at cosmos.phy.tufts.edu> wrote:
> On Monday 29 August 2005 10:07, Alec Munro wrote:
> > def __setattr__(self, name, obj):
> > if self.mapping.has_key(name):
> > IDemographicInfo[name].validate(obj)
> > self.mapping[name] = obj
> > def __getattr__(self, name):
> > if self.mapping.has_key(name):
> > return self.mapping[name]
> 
> This looks correct, except that you want to bind the field before validation.
> 
> bound = IDemographic[name].bind(self.context)
> bound.validate(obj)
> 
> Regards,
> Stephan
> --
> Stephan Richter
> CBU Physics & Chemistry (B.S.) / Tufts Physics (Ph.D. student)
> Web2k - Web Software Design, Development and Training
> 
Thanks, it seemed to work, once I realized that I was creating another
infinite recursion when it accessed self.mapping. Also, apparently
__getattr__ is actually __getattribute__. I'll do a little more
experimentation, but I think it I've got what I need.

Thanks again,

Alec


More information about the Zope3-users mailing list