[ZPT] Passing parameter to Python Script

Harry Wilkinson harryw@nipltd.com
Thu, 18 Apr 2002 16:46:09 +0100


On Thursday 18 April 2002 7:42 pm, Grant Thibdeau wrote:
> Hello Folks, this is another simple question that I seem to be having
> issues with, i'm attempting to get a value from my url, it's appended to
> the end like --
>
> http://www.link.com/PageTemplate?rebate=100
>
> So that goes to my PageTemplate, which has several macros in it, one of the
> macros calls a python script which does some stuff with the rebate number
> in the url. How do I pass the value from the url to the script call in the
> zpt? This is what my script call looks like --
>
>
>        <p tal:content="root/Lens123/Python/pyGetRebate"
>
> but whenever I try to add anything to the call, it starts looking for the
> literal thing.  So I tried to do a python statement like so --
>
>         <p tal:content="python: container.pyGetRebate()"
>
> which gives me a TALES error, a couple other iterations of it do not work
> either, such as dropping the parentheses and rebate is a parameter on the
> script, would I need other parameters? Any help or suggestions would be
> greatly appreciated, or if this isn't the correct idea behind using this
> please let me know.  In my script i'm trying to assign the rebate number
> like so --
>
> argRebateNumber=form['rebate']
>
> Could I be trying to assign it incorrectly too?  Thanks!

This sounds simple enough, if all you want to do is pass a variable from the 
request into a python script:

<p tal:content="python: container.pyGetRebate( rebate=request['rebate'] )"

then just let your script know that it's expecting the 'rebate' variable as a 
parameter.