[Zope] Passing Arguments to ZSQL Method from Python Script

Jim Penny jpenny@universal-fasteners.com
Wed, 25 Sep 2002 14:54:04 -0400


On Wed, Sep 25, 2002 at 11:39:36AM -0700, Chris A. Bruce wrote:
> Well, if the variables are in REQUEST, zope will bind them to the
> parameters of the ZSQL Method--as long as the names match.  So, I could
> in effect call <dtml-call sql_insert> without passing any arguments.
> But I want to mimick this in Python Script.  Another "convincing"
> argument can be found in the Zope Book:
> 
> "If you call a Z SQL Method without argument from DTML, the arguments
> are automatically collected from the environment."
> http://www.zope.org/Documentation/Books/ZopeBook/current/RelationalDatab
> ases.stx#3-66
> 
> I am sure there is a way to do this in script, but I don't know how to.
> I am hoping that someone on this list knows.
> 
> Are you convinced now?
> 
> Oh, I think I have html turned off now.

OK, suppose your REQUEST object is named request, as in the sample
Script (Python).

Then use

    container.sql_insert(request)

You arguments will be marshalled for you, as above.

Jim Penny

> 
> 
> Chris
>  
> 
> 
> -----Original Message-----
> From: Chris Withers [mailto:chrisw@nipltd.com] 
> Sent: Wednesday, September 25, 2002 6:11 AM
> To: Chris A. Bruce
> Cc: Meilicke, Scott; zope@zope.org
> Subject: Re: [Zope] Passing Arguments to ZSQL Method from Python Script
> 
> 
> 
> Chris A. Bruce wrote:
> > Yes, that would work.  But I am trying to do it without all of that.
> > Dtml does this automatically, 
> 
> Convince us that it does ;-)
> 
> And stop posting in HTML...
> 
> cheers,
> 
> Chris
> 
> 
> _______________________________________________
> 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 )
>