[Zope] Passing Arguments to ZSQL Method from Python Script
Chris A. Bruce
cbruce@sleeter.com
Wed, 25 Sep 2002 14:47:22 -0700
But here is the code that I am using, you will notice that the user
attributes are NOT in the REQUEST object:
for user in context.Users.RegistrationInfo.objectValues("UserInfo"):
context.sql_users_insert(user)
=20
The sql_users_insert takes a bunch of parameters and the "user" object
above is a ZClass with properties that have exact names as parameters
for zsql method.
Chris
=20
=20
-----Original Message-----
From: Jim Penny [mailto:jpenny@universal-fasteners.com]=20
Sent: Wednesday, September 25, 2002 11:54 AM
To: Chris A. Bruce; zope@zope.org
Subject: Re: [Zope] Passing Arguments to ZSQL Method from Python Script
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=20
> parameters of the ZSQL Method--as long as the names match. So, I=20
> could in effect call <dtml-call sql_insert> without passing any=20
> arguments. But I want to mimick this in Python Script. Another=20
> "convincing" argument can be found in the Zope Book:
>=20
> "If you call a Z SQL Method without argument from DTML, the arguments=20
> are automatically collected from the environment."=20
> http://www.zope.org/Documentation/Books/ZopeBook/current/RelationalDat
> ab
> ases.stx#3-66
>=20
> I am sure there is a way to do this in script, but I don't know how=20
> to. I am hoping that someone on this list knows.
>=20
> Are you convinced now?
>=20
> 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
>=20
>=20
> Chris
> =20
>=20
>=20
> -----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
>=20
>=20
>=20
> Chris A. Bruce wrote:
> > Yes, that would work. But I am trying to do it without all of that.
> > Dtml does this automatically,
>=20
> Convince us that it does ;-)
>=20
> And stop posting in HTML...
>=20
> cheers,
>=20
> Chris
>=20
>=20
> _______________________________________________
> Zope maillist - Zope@zope.org=20
> 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 )
>=20