On Fri, 13 Oct 2000 11:48:39 +0100, Chris Withers <[EMAIL PROTECTED]>

>I have a Python Product Class, with a method, a_method, that gets called
>from some of the Python Product's management screens (encapsulation is
>good ;-)
>This method needs several parameters from the namespace, so when it's
>called I was hoping I wouldn't have to do something nasty and clunky
><dtml-var "a_method(param1,param2,param3)">
>Given my recently acquired __call__ Zen, I thought 'No problem...' and
>tried to define the method as follows:
>    isDocTemplate = 1
>    def a_method(self, ignored=None, md=None):
>...with the hope I'd just be able to do <dtml-var a_method> and pluck
>the stuff from md.
>No dice.
>md and ignored turn up as None from all the <dtml-var a_method> calls.
>What am I doing wrong? How can I get access to the namespace in a method
>of a class like this?

You need to have the isDocTemplate=1 as an attribute of the method
object itself, not the class that contains the method.

You also need some extra voodoo if you want to call the method
directly from ZPublisher (by including the method name in a url). Here
a link to a wrapper that does it all....


you would use....

    def a_method(self,md):
    a_method = FunctionTemplate(a_method)

Toby Dickenson

Zope-Dev maillist  -  [EMAIL PROTECTED]
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope )

Reply via email to