Hi, I have a method method_x. If there is a method_y in the same folder (not acquired!) as where method_x is being executed, I want to do one action, otherwise, some other. I tried this <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 Any help?
Use the only attribute: <dtml-with aq_explicit only> Cheers. -- Andy McKay. ----- Original Message ----- From: "Dan Keshet" <dkesh@channel1.com> To: <zope@zope.org> Sent: Tuesday, July 17, 2001 1:19 PM Subject: [Zope] stopping acquisition
Hi,
I have a method method_x.
If there is a method_y in the same folder (not acquired!) as where method_x is being executed, I want to do one action, otherwise, some other.
I tried this
<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
Any help?
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
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
participants (3)
-
Andy McKay -
Dan Keshet -
Dieter Maurer