26 May
2005
26 May
'05
3:48 p.m.
On Wed, May 25, 2005 at 09:03:13PM +0100, Chris Withers wrote:
if getattr(thefolder.aq_inner.aq_explicit,the_id,None):
You are aware that this is in general *NOT* an emulation of "hasattr".
I didn't say it was ;-)
It may fail e.g. for properties.
How would it fail for properties?
Well, it doesn't distinguish between an attribute which doesn't exist and an attribute which has any false value. This makes it unsuitable as a hasattr() replacement IMHO. It feels kind of hacky, but for this kind of thing I've used the "marker" pattern that you find throughout the Zope source: marker = () if getattr(some_object, marker) is not marker: ... -- Paul Winkler http://www.slinkp.com