[Zope-dev] Where is has() defined?

Kyler B. Laird laird@ecn.purdue.edu
Wed, 05 Sep 2001 12:50:01 -0500


On Wed, 05 Sep 2001 10:32:12 -0700 you wrote:

>> > I'm trying to read
>> >       python/Products/PageTemplates/Expressions.py
>> > and
>> >       python/OFS/Traversable.py
>> > but I am at a loss for the definition of has().
>> 
>> Just add "has=hasattr" right after "get=getattr" (line 145 of
>> Traversable.py).
>
>I think he wanted to know where it was defined, not where he can define
>it.

Well...it's a little of each that I sought.

>Kyler, take a look at the definition for the restrictedTraverse method
>in Expressions.py:
>
>def restrictedTraverse(self, path, securityManager,
>                       get=getattr, has=hasattr, N=None, M=[]):
>
>That's where it's defined.

That makes sense, and I did miss that for
Expressions.py.  (We had not noticed a problem
with it, but it showed up when I started
searching for "has()".)

Unfortunately, the same does not appear to be
the case for Traversable.py.  I do not see it
being defined at all, but Evan's suggestion
to patch in "has=hasattr" should do the trick.

Is there any reason that I should *not* define
it like this?  (I'm assuming that this is just
a temporary kludge until a fix comes out.)  A
quick grep of the code does not reveal any
calls to unrestrictedTraverse() that include a
definition for "has".

Thank you for the help!

--kyler