Hi Folks. Can some explain to me how I access DTML vars from a called python script? From what I've gleamed from the Zope book, I can set the Namespace binding for the script to expose the DTML namespace, but I'm having problems accessing it. I've tried _.varname, which gave me an attribute error and _varname is an illegal variable name. The variable is accessible from the calling DTML method via dtml-var Cheers. Lee. -- Lee Shakespeare : lee at webfoundry dot co dot uk
script? From what I've gleamed from the Zope book, I can set the Namespace binding for the script to expose the DTML namespace, but I'm having problems accessing it.
I've tried _.varname, which gave me an attribute error and _varname is an illegal variable name.
If you've successfully bound the namespace to _, then I believe you want: _['varname'] cheers, Chris . o O (Oh if only _ had a 'get' method with a default option)
Chris Withers asked about this some time recently (Passing namespace from DTML to Python) and got an answer by Evan Simpson to call the python method as follows: python_method(_=_) On Tue, Jun 05, 2001 at 03:08:17PM +0100, Lee Shakespeare wrote:
Hi Folks.
Can some explain to me how I access DTML vars from a called python script? From what I've gleamed from the Zope book, I can set the Namespace binding for the script to expose the DTML namespace, but I'm having problems accessing it.
I've tried _.varname, which gave me an attribute error and _varname is an illegal variable name.
The variable is accessible from the calling DTML method via dtml-var
Cheers. Lee.
-- Lee Shakespeare : lee at webfoundry dot co dot uk
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
-- ------------------------------------------------------ Andres Corrada-Emmanuel Email: andres@corrada.com Internet Programming http://www.mamey.com ------------------------------------------------------
From: "Lee Shakespeare" <lee@webfoundry.co.uk>
I've tried _.varname, which gave me an attribute error and _varname is an illegal variable name.
You use the namespace in Scripts in exactly the same way as in DTML expressions. Since you would have to write: <dtml-var expr="_['varname']"> or <dtml-var expr="_.getitem('varname', 0)"> ...to get the rendered or unrendered version of 'varname', respectively, in your Script you do: x = _['varname'] y = _.getitem('varname', 0) Cheers, Evan @ digicool & 4-am
participants (4)
-
andresï¼ corrada.com -
Chris Withers -
Evan Simpson -
Lee Shakespeare