Ben Avery writes:
I want to test to see if a folder contains a dtml method with a known id. how do I do this from python?
I've tried if context.data.news[ object_id ] which breaks with a key error, if it doesn't exist.
I want something like context.data.news.has_key( object_id ) but object manager doesn't seem to have any methods like that.
and doing a try, and catching key errors seems a messy way to do it. You have several options:
* "try: ... except: ..." around the code above * "hasattr(object.aq_explicit, attribute)" This is not fool proof * an external method "hasOwnAttr" providing the missing function from Acquisition import aq_base def hasOwnAttr(self,attr): return hasattr(aq_base(self),attr) * making the above method available to DTML and Python Script by modifying the Zope source. Dieter