[Zope] exceptions/documentation problem
Dieter Maurer
dieter at handshake.de
Tue Jul 20 14:37:56 EDT 2004
Marcin Dobrzycki wrote at 2004-7-19 10:20 +0200:
>Dieter Maurer wrote at July 16, 2004 9:36 pm:
>> Marcin Dobrzycki wrote at 2004-7-16 13:11 +0200:
>>>Hi, this mail is because of lack of Zope documentation. I got to call
>>> method of one of the ZopeObjects (Folder). Is there any docs about what
>>> exceptions can be thrown? Could you give me some links to it.Thanks.
>>
>> Why do you want this information?
>>
>
>It's my way to find out if the specified folder exists.
>
>> Note that it is *very* dangerous to catch exceptions.
>>
>Is there any better way? If so, I didn't find it. Didn't find something
>like folder_object.has_child('my_sub_folder') method. And listing all
>subobjects' id in container, and comparing each id with folder I want to
>add is, let's say, a little
>bit awkward.
Make a Python Script, say "has_unacquired", with parameter
"attr" and the following body:
return hasattr(context.aq_inner.aq_parent, attr)
Use "obj.has_unacquired(attr)"
whenever you want to check, whether "obj" has attribute "attr".
This will work because most Zope containers expose their content
as attributes.
You may get "True" back also for non content attributes but
usually, this is precisely what you want (you will not be able
to create a content object with an id conflicting with another attribute).
--
Dieter
More information about the Zope
mailing list