[Zope] Indirect method lookup? (Update)

Kapil Thangavelu kthangavelu@earthlink.net
Tue, 22 Aug 2000 18:06:29 -0700


Jeff Hoffman wrote:
> 
> Ok, knowing more about what's going on, now, I figured I would send an
> update to the list and hope it jars someone's memory.
> 
> Here's what I am trying to do:
> 
> I have a ZClass, MyTestClass. MyTestClass has two methods: method1, and
> method2. There are two other methods, showMethods and showMethods2, but
> they are only needed for the purpose of demonstration.
> 
> I created an instance of MyTestClass with an id of 'test'.
d> 
> showMethods (a DTMLMethod) is defined as:
> 
>   <dtml-var standard_html_header>
>   <p>
>   method1 = <dtml-var "_.hasattr(this(), 'method1')"><br>
>   method2 = <dtml-var "_.hasattr(this(), 'method2')"><br>
>   nullmethod = <dtml-var "_.hasattr(this(), 'nullmethod')">
>   </p>
> 
>   <dtml-var standard_html_footer>
> 
> and, when invoked on my 'test' instance, returns:
> 
>   method1 = 1
>   method2 = 1
>   nullmethod = 0
> 
> We're cookin'. Now, I need to get the same results with a PythonMethod.
> showMethods2 (a PythonMethod) is defined as:
> 
>   print _.hasattr(self, 'method1')
>   print _.hasattr(self, 'method2')
>   print _.hasattr(self, 'nullmethod')
>   return printed
> 
> which, when invoked on my 'test' instance, returns:
> 
>   0
>   0
>   0
> 
> I have tried every permutation of Python code I can, and none work as the
> DTML Method does. Somebody? Anybody? :-)


hmmm... what are the args to the method and how are you calling it? from
your spelling i assume you mean a web PythonMethod..


if your zclass is an objectmanager why not
<dtml-var "'method1' in self.objectIds(['DTML Methods'])">


anyways, i tried your example and it worked fine for me. i tried it with
a zclass whose only base class was dtml doc.

my pythonmethod 
accepted the object as an arg.

body
return hasattr(ob, 'method1')

returned the correct results. 1


Kapil