[Zope] Object Acquisition

Samir Mishra SamirMishra@cbuae.gov.ae
Wed, 26 Feb 2003 15:11:34 +0400


Thanks. That worked. 

I think I saw docs on aq_* methods, I'll look it up again.

Samir.



-----Original Message-----
From: Thierry FLORAC [mailto:thierry.florac@onf.fr]
Sent: Wednesday, February 26, 2003 14:25
To: Samir Mishra; 'zope@zope.org'
Subject: Re: [Zope] Object Acquisition


On Wednesday 26 February 2003 11:09, Samir Mishra wrote:
> Sorry to be a bother, seems trivial, just can't seem to find the right
> syntax for it...
>
> How do I check if a particular object exists ONLY in the current folder
> (the context) and is not being acquired?
>
> The script I have is -
>
> ==================================
>
> """
> Add single folder along with manager/user programmatically to current
> folder Parameter: folderList (a list)
> """
>
> curFolder = context #current context, where the user is
>
> folderName = folderList[0]
> folderTitle = folderList[1]
>
> if not hasattr(curFolder, folderName):
>     ## create the folder
>     curFolder.manage_addFolder(folderName, folderTitle, 0, 1)
>     return 1
> else:
>     return 0

I think you could make it work with :

  if folderName not in curFolder.objectIds():
    ...
or

  if not hasattr (curFolder.aq_explicit, folderName):
    ...

Not tested :-((

Thierry.