[Zope] Finding an object in a folder

Alec Mitchell apm13 at columbia.edu
Thu May 26 19:03:26 EDT 2005


On Thursday 26 May 2005 02:52 pm, Dieter Maurer wrote:
> Chris Withers wrote at 2005-5-25 21:03 +0100:
> > ...
> >
> >> I strongly argue against it. Fix "hasattr" in the Zope context,
> >> instead!
> >
> >Make it so! :-)

I'd add the ability to turn on/off acquisition (off by default, import aq_base 
somewhere above), and get rid of the required marker parameter:

     _marker = []
     def hasattr(obj, attr, acquire=False):
         if not acquire:
             obj = aq_base(obj)
	 a = getattr(obj, attr, _marker)
	 return a is not _marker

     import __builtin__
     __builtin__.hasattr = hasattr
>
> Easy enough, isn't it?
>
> Way easier than to change "hasattr" anywhere it is now used.
>
>
> Now, there need only to be someone who checks it in.

This would be lovely. :-)

Alec


More information about the Zope mailing list