[Zope] ONLY in python script

Peter Bengtsson peter@grenna.net
Mon, 23 Apr 2001 10:23:53 +0200


No 'aq_explicit' doesn't work.

Again:
/pythonscript_pys
  /main
     /zopestuff
        /pythononly
     /misc
     /otherstuff

I want to, in pythonscript_pys, test if certain objects exists. I want to do
this without aquisition.
To check if there is an object INSIDE folder 'zopestuff' called 'main'
should return FALSE...

I try:

if hasattr(context.main.zopestuff.aq_explicit, 'main'):
  # inside folder /main/zopestuff, there is NO object called 'main'
else:
  # inside folder /main/zopestuff, there IS an object called 'main'


...but it returns TRUE!!

Help appreciated.
Peter

> -----Message d'origine-----
> De : cduncan@kaivo.com [mailto:cduncan@kaivo.com]
> Envoye : jeudi 19 avril 2001 18:00
> A : Peter Bengtsson
> Cc : zope@zope.org
> Objet : Re: [Zope] ONLY in python script
>
>
> 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
> `------------------>