[Zope] ONLY in python script
Casey Duncan
cduncan@kaivo.com
Thu, 19 Apr 2001 09:59:52 -0600
Peter Bengtsson wrote:
>
> assuming this folder structure:
>
> /main
> /zopestuff
> /misc
> /otherstuff
>
> If I do this in python script:
>
> if hasattr(context.main,'zopestuff'):
> # it returns TRUE!!
> return "found in /main/"
>
> But also, if I do it in or /misc or /otherstuff
>
> if hasattr(context.main.misc,'zopestuff'):
> # if returns TRUE!
> return "found in /main/misc/"
>
> This is because of aquisition, right.
> So HOW do I prevent this it happen? I want it only to true with what is
> called ONLY in DTML.
>
if hasattr(context.main.aq_explicit, 'zopestuff'):
...
(aq_explicit turns off implicit aquisition)
or
if 'zopestuff' in context.main.objectIds():
...
--
| Casey Duncan
| Kaivo, Inc.
| cduncan@kaivo.com
`------------------>