[Zope] Calling a dtml method from a product
hans
hans@beehive.de
Wed, 03 Apr 2002 18:42:20 +0100
Geoff Armstrong wrote:
> At 15:54 +0100 3/4/02, hans wrote:
>
> ><dtml-call "REQUEST.set( 'yourname', yourvalue)">
>
> Yes, I have a number of such calls in the DTMLMethod I'm attempting
> to call from the python product.
i understand, that you call a DTMLMethod, which contains these calls
> >> I know this must seem like a dumb question; but can you tell me how
> >> to pass an empty REQUEST object in the call, so the DTMLMethod can
> >> set and make use of these variables?
> >>
> > > __call__(myDTMLMethod, REQUEST???)
from the top of my head
myResult_if_any = myDTMLMethod(self, REQUEST=REQUEST)
or
myResult_if_any = myDTMLMethod(self)
This effects a "binding" of the REQUEST object (right hand side)
to a parameter named REQUEST (in the second case default = {}
> >a) REQUEST is an object that seemingly behaves just like a python
> >dictionary
> >b) the __call__-method of DTMLMethod has REQUEST={},
> >so by default if no 2nd parameter is given, it is empty. Note that
> >DTMLMethods
> >are usually interpreted in the context (=namespace) of their caller.
= client
> >c) the third parameter **kw is a sequence of keyword parameters.
>
> So does that mean I need to pass an empty dictionary as the second
> parameter to _call_ so that my DTMLMethod will have a REQUEST object
> that it can start filling with variables using <dtml-call
> "REQUEST.set( 'yourname', yourvalue)"> ?
>
> Could you provide the exact syntax I need to use in _call_ ? Whatever
> I try, I always get the error "global name 'REQUEST' is not defined"?
>
> Presumably because the DTMLMethod I'm calling is trying to set
> variables in a REQUEST object; but it's not getting one, and I still
> don't understand how to provide this. I'll also need to provide some
> other variables to the DTMLMethod. I guess I need to use **kw for
> that? Again the exact syntax I need to use, by example, would be
> appreciated.
>
> The end of the traceback is as following:
>
> (Object: REQUEST.set('newsMgr', id))
> (Info : REQUEST)
> File <string>, line 2, in f
> NameError: (see above)
The name "REQUEST" is not bound to
-------------------------------------------------------------
Who's got only a hammer sees the world as a nail
hans augustin (software developer) hans@beehive.de
beehive elektronische medien GmbH http://www.beehive.de
phone: +49 30 847-82 0 fax: +49 30 847-82 299