[Zope-dev] calling DTML method from python script in Zope

Tres Seaver tseaver at zope.com
Mon Nov 24 06:49:24 EST 2003


On Sun, 2003-11-23 at 22:59, scripts-urban at imeme.net wrote:
> of course I looked over at ZopeLabs;
> 
> http://www.zopelabs.com/cookbook/992031125
> 
> and while this shed some light on the situtation, it hardly solved the
> problem.
> 
> the script calls a DTML method in the same folder from which it resides &
> was called from

When calling a DTML method from Python, you need to pass in the
arguments it expects:

    def __call__(self, client=None, REQUEST={}, RESPONSE=None, **kw):

While the declaration makes the arguments optional, the template won't
be able to bind names unless you pass them.  In your case, I would try:

    dtml = container.your_template_name_here
    req = context.REQUEST
    return dtml( container, req, req['RESPONSE'] )

Tres.
-- 
===============================================================
Tres Seaver                                tseaver at zope.com
Zope Corporation      "Zope Dealers"       http://www.zope.com




More information about the Zope-Dev mailing list