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 ================================== Unfortunately, if FolderName exists in the parent (or above) folder, the script will return 0. I only want to look in the context folder for the existence of folerName. Thanks again. Samir.
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.
Samir Mishra wrote at 2003-2-26 14:09 +0400:
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?
Search the collector for the "hasattr_unacquired" patch. "aq_explicite" does not work reliably. Dieter
Thanks a lot for the answer and the patch, Dieter. Could you please describe when "aq_explicit" is not reliable for checking the existence of unacquired attributes? I ask because we use it quite often, and maybe others also use it. Best regards, Luciano On quarta-feira, fev 26, 2003, at 16:12 America/Sao_Paulo, Dieter Maurer wrote:
Samir Mishra wrote at 2003-2-26 14:09 +0400:
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?
Search the collector for the "hasattr_unacquired" patch.
"aq_explicite" does not work reliably.
Dieter
_______________________________________________ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
Luciano Ramalho wrote at 2003-2-26 17:56 -0300:
Thanks a lot for the answer and the patch, Dieter. Could you please describe when "aq_explicit" is not reliable for checking the existence of unacquired attributes? I ask because we use it quite often, and maybe others also use it.
Please search the mailing list archives... I explained it several times (and am tired to repeat it again). For the latest practical problem, search for a post from "Volker Wend". Dieter
participants (4)
-
Dieter Maurer -
Luciano Ramalho -
Samir Mishra -
Thierry FLORAC