[Zope] PythonScript equivalent to dtml-with only
Jerome Alet
alet@unice.fr
Thu, 12 Apr 2001 01:26:27 +0200
On Thu, Apr 12, 2001 at 12:38:51AM +0200, Dieter Maurer wrote:
> 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...
Thank you very much !
Finally I've found another solution, searching 'index_html' in
the ids of the objects returned by
folder.objectValues(['DTML Method', 'DTML Document'])
should always work.
thanks again.
Jerome Alet