[Zope] stopping acquisition
Dieter Maurer
dieter@handshake.de
Wed, 18 Jul 2001 21:04:59 +0200 (CEST)
Dan Keshet writes:
> ...
> <dtml-with aq_explicit>
> <dtml-if method_y>
> Yup
> <dtml-else>
> Nope
> </dtml-if>
> </dtml-with>
>
> But it says "Yup" in Folders without a method_y
"aq_explicit" is not fail safe.
If you know that your objects are always folders, you
can use that folders provide access to their content via
subscription and use the following Python Script:
hasChild(folder,id):
try: folder[id]; return 1
except KeyError: return 0
If your objects are arbitrary, you should use an external
method:
hasOwnAttribute(object,attr):
o= getattr(object,'aq_base',object)
return hasattr(o,attr)
Of course, you can make a HotFix product (--> HowTo on Zope.org)
to provide such a beast as "TemplateDict" attribute
(I think, Zope should have such a method builtin).
Dieter