[Zope] PythonScript equivalent to dtml-with only

Dieter Maurer dieter@handshake.de
Thu, 12 Apr 2001 00:38:51 +0200 (CEST)


Jerome Alet writes:
 > ....
 > mylist = []
 > for folder in context.objectValues(['Folder']) :
 > 	if hasattr(folder, 'index_html') :
 > 		mylist.append(folder)
 > return mylist
 > --- CUT ---
 > 
 > The problem with the above code is that if index_html is acquired from the
 > parent folders my hasattr test is true. I want it to be false in the case
 > of acquisition.
Most of the time (in all practical cases),

     if hasattr(folder.aq_explicit, 'index_html'):

will work.

When you search the mailing list archives for a
post "Unexpected acqusition behaviour", you will
see some cases, where it will not work.

A safe solution is to use "aq_base" (instead of "aq_explicit").
"aq_base", however, is only be allowed in External Methods...


Dieter