[Zope] RE: Evaluating dtml from python
Chuck Burdick (TT)
chuck.burdick@tradingtechnologies.com
Mon, 20 Dec 1999 17:21:04 -0600
A while after I submitted this, I figured it out.
Here's the fix:
return HTML.__call__(self)
This evaluates the string as DTML using the environment that called the
python method.
The example is modified below:
<<<Example>>>
from Globals import HTML
def myproc():
mystring = "<dtml-in mysqlselect><dtml-var id>, <dtml-var
value></dtml-in>"
mydtml = HTML(mystring, globals())
return HTML.__call__(self)
<<<End of Example>>>
> -----Original Message-----
> From: Chuck Burdick (TT)
> Sent: Monday, December 20, 1999 11:05 AM
> To: 'zope@zope.org'
> Subject: Evaluating dtml from python
>
> I have a string that I want to evaluate as dtml from within a python
> method. How do I send the namespace to the HTML object so that it
> understands the <dtml-var> tags?
>
> <<<Example>>>
>
> from Globals import HTML
>
> def myproc
> mystring = "<dtml-in mysqlselect><dtml-var id>, <dtml-var
> value></dtml-in>"
> mydtml = HTML(mystring, globals())
> return HTML.__call__()
>
> <<<End of Example>>>
>
> Right now when I call this from Zope, it will interpret standard HTML tags
> just fine. Zope appears to parse the dtml tags, but I'm getting a
> KeyError on 'mysqlselect' which leads me to think that the HTML object
> does is not inheriting (or otherwise receiving) the current namespace.
>
> How do I pass the namespace? Is there a better way to do what I want?
>
> Thanks in advance,
> Chuck Burdick
>
> Web Administrator / Developer
> Trading Technologies, Inc.
>
> chuck.burdick@tradingtechnologies.com
> (847) 424-8844
>