[ZPT] Re: ZPT, ZSQL Method and Python script
Wade Leftwich
wade at lightlink.com
Sat May 10 14:46:35 EDT 2003
> Date: Fri, 09 May 2003 14:26:40 -0500
> From: Evan Simpson <evan at 4-am.com>
> Subject: [ZPT] Re: ZPT, ZSQL Method and Python script
> To: zpt at zope.org
> Message-ID: <3EBC00F0.3080003 at 4-am.com>
> Content-Type: text/plain; charset=us-ascii; format=flowed
>
> James G. Webster wrote:
>
>>happening in the script of the Z SQL method. I'm passing the
>>parameters to the SQL method as "request['foo'],request['bar'].
>
>
> Unless you are passing a single object that contains all of your data,
> you need to use named parameters or none at all with Z SQL Methods.
>
> If your parameters are actually 'foo' and 'bar', and are coming from the
> request, you can simply write:
>
> mySqlMethod()
>
> ...since in this case it will automatically look for parameters in
> REQUEST. If you need to massage/substitute parameter values, you use:
>
> mySqlMethod(foo=32, bar=REQUEST['bar'])
>
> Cheers,
>
> Evan @ 4-am
>
The third way to pass parameters to a ZSQL method is via a dict:
mySqlMethod({'foo':32, 'bar':REQUEST['bar']})
This comes in handy if the ZSQL method has optional params. So if foo is
optional in mySqlMethod, you can say
argD = {}
argD['bar'] = REQUEST.get('bar')
if foo is not None:
argD['foo'] = foo
mySqlMethod(argD)
-- Wade Leftwich
Ithaca, NY
More information about the ZPT
mailing list