Calling Page Template with Dictionaries
We know we can do this: python script: foo='bar' return context['page_template'](arg=foo) and in page_template: Hello, arg is <p tal:content="string:${options/arg}"></p> What I'm hoping to find out, though, is whether I could call a ZPT with a dictionary. My initial effort: PS: d = {} d['arg'] = 'bar' return context['page_template'](d) page_template: Hello, arg is <p tal:content="string:${options/arg}"></p> Resulted in Error Type: Undefined Error Value: arg not found in 'options/arg', at line 12, column 11 Suggestions? -roy Content-Type: text/plain; charset="iso-8859-1" ------------------------------------------------- PLEASE READ THIS WARNING: All e-mail sent to or from this address will be received or otherwise recorded by the Fisher Investments corporate e-mail system and is subject to archival, monitoring or review by, and/or disclosure to, someone other than the recipient.
On Tue, Jul 22, 2003 at 06:48:57PM -0700, Roy Rapoport wrote:
What I'm hoping to find out, though, is whether I could call a ZPT with a dictionary. My initial effort: PS: d = {} d['arg'] = 'bar' return context['page_template'](d)
Untested, but I think the answer here is a standard python idiom: return context['page_template'](**d) -- Paul Winkler http://www.slinkp.com Look! Up in the sky! It's NINJA POLY BUTTER CHURN! (random hero from isometric.spaceninja.com)
Roy Rapoport wrote:
We know we can do this: python script: foo='bar' return context['page_template'](arg=foo)
and in page_template: Hello, arg is <p tal:content="string:${options/arg}"></p>
What I'm hoping to find out, though, is whether I could call a ZPT with a dictionary. My initial effort: PS: d = {} d['arg'] = 'bar' return context['page_template'](d)
above you used the call form: var=value why do it different for your dictionary? Semantically there is no difference what you pass. IF the foo above is a dictionary, you use its values via options/arg/element Reagards Tino Wildenhain
page_template: Hello, arg is <p tal:content="string:${options/arg}"></p>
Resulted in Error Type: Undefined Error Value: arg not found in 'options/arg', at line 12, column 11
Suggestions?
-roy
Content-Type: text/plain; charset="iso-8859-1"
------------------------------------------------- PLEASE READ THIS WARNING: All e-mail sent to or from this address will be received or otherwise recorded by the Fisher Investments corporate e-mail system and is subject to archival, monitoring or review by, and/or disclosure to, someone other than the recipient.
_______________________________________________ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
participants (4)
-
Chris Withers -
Paul Winkler -
Roy Rapoport -
Tino Wildenhain