[Zope] Passing Arguments to ZSQL Method from Python Script

Chris A. Bruce cbruce@sleeter.com
Tue, 24 Sep 2002 16:16:36 -0700


This is a multi-part message in MIME format.

------_=_NextPart_001_01C26420.6DAD1FE0
Content-Type: text/plain;
	charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

Yes, that would work.  But I am trying to do it without all of that.
Dtml does this automatically, so I am not sure if I need to somehow add
user to the REQUEST or what.  I am pretty sure there is a way to do it.

=20

Thanks,

=20

=20

Chris Bruce

=20

=20

-----Original Message-----
From: Meilicke, Scott [mailto:scott.meilicke@intp.com]=20
Sent: Tuesday, September 24, 2002 3:59 PM
To: Chris A. Bruce; zope@zope.org
Subject: RE: [Zope] Passing Arguments to ZSQL Method from Python Script

=20

Would something like this work:=20

for user in context.Users.RegistrationInfo.objectValues("UserInfo"):=20
  context.sql_users_insert(first_name=3Duser.first_name,
last_name=3Duser.last_name, etc.)=20

if user is a dictionary, the zsql arguments would be
first_name=3Duser[first_name], last_name=3Duser[last_name], etc.=20

-Scott=20

-----Original Message-----=20
From: Chris A. Bruce [mailto:cbruce@sleeter.com]=20
Sent: Tuesday, September 24, 2002 3:36 PM=20
To: zope@zope.org=20
Subject: [Zope] Passing Arguments to ZSQL Method from Python Script=20

=20

Is there an easy way to bind the attributes of an object into the
parameters of a zsql method?  I am trying to do something like this in
Python Script:

for user in context.Users.RegistrationInfo.objectValues("UserInfo"):=20
  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.

=20

Thanks for any help,=20

=20

Chris Bruce=20
The information contained in this email message may be privileged and is
confidential information intended only for the use of the recipient or
any employee or agent responsible for delivering it to the intended
recipient.  Any unauthorized use, distribution or copying of this
information is strictly prohibited and may be unlawful.  If you have
received this communication in error, please notify the sender
immediately and destroy the original message and all attachments from
your electronic files.


------_=_NextPart_001_01C26420.6DAD1FE0
Content-Type: text/html;
	charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<html>

<head>
<META HTTP-EQUIV=3D"Content-Type" CONTENT=3D"text/html; =
charset=3Dus-ascii">


<meta name=3DGenerator content=3D"Microsoft Word 10 (filtered)">
<title>RE: [Zope] Passing Arguments to ZSQL Method from Python =
Script</title>

<style>
<!--
 /* Font Definitions */
 @font-face
	{font-family:Tahoma;
	panose-1:2 11 6 4 3 5 4 4 2 4;}
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
	{margin:0in;
	margin-bottom:.0001pt;
	font-size:12.0pt;
	font-family:"Times New Roman";}
a:link, span.MsoHyperlink
	{color:blue;
	text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
	{color:blue;
	text-decoration:underline;}
p
	{margin-right:0in;
	margin-left:0in;
	font-size:12.0pt;
	font-family:"Times New Roman";}
span.EmailStyle18
	{font-family:Arial;
	color:navy;}
@page Section1
	{size:8.5in 11.0in;
	margin:1.0in 1.25in 1.0in 1.25in;}
div.Section1
	{page:Section1;}
-->
</style>

</head>

<body lang=3DEN-US link=3Dblue vlink=3Dblue>

<div class=3DSection1>

<p class=3DMsoNormal><font size=3D2 color=3Dnavy face=3DArial><span =
style=3D'font-size:
10.0pt;font-family:Arial;color:navy'>Yes, that would work.&nbsp; But I =
am trying to
do it without all of that.&nbsp; Dtml does this automatically, so I am =
not sure if I
need to somehow add user to the REQUEST or what.&nbsp; I am pretty sure =
there is a
way to do it.</span></font></p>

<p class=3DMsoNormal><font size=3D2 color=3Dnavy face=3DArial><span =
style=3D'font-size:
10.0pt;font-family:Arial;color:navy'>&nbsp;</span></font></p>

<p class=3DMsoNormal><font size=3D2 color=3Dnavy face=3DArial><span =
style=3D'font-size:
10.0pt;font-family:Arial;color:navy'>Thanks,</span></font></p>

<p class=3DMsoNormal><font size=3D2 color=3Dnavy face=3DArial><span =
style=3D'font-size:
10.0pt;font-family:Arial;color:navy'>&nbsp;</span></font></p>

<p class=3DMsoNormal><font size=3D2 color=3Dnavy face=3DArial><span =
style=3D'font-size:
10.0pt;font-family:Arial;color:navy'>&nbsp;</span></font></p>

<div>

<p class=3DMsoNormal><font size=3D2 color=3Dnavy face=3DArial><span =
style=3D'font-size:
10.0pt;font-family:Arial;color:navy'>Chris Bruce</span></font></p>

<p class=3DMsoNormal><font size=3D3 color=3Dnavy face=3D"Times New =
Roman"><span
style=3D'font-size:12.0pt;color:navy'>&nbsp;</span></font></p>

<p class=3DMsoNormal><font size=3D3 color=3Dnavy face=3D"Times New =
Roman"><span
style=3D'font-size:12.0pt;color:navy'>&nbsp;</span></font></p>

</div>

<p class=3DMsoNormal style=3D'margin-left:.5in'><font size=3D2 =
face=3DTahoma><span
style=3D'font-size:10.0pt;font-family:Tahoma'>-----Original =
Message-----<br>
<b><span style=3D'font-weight:bold'>From:</span></b> Meilicke, Scott
[mailto:scott.meilicke@intp.com] <br>
<b><span style=3D'font-weight:bold'>Sent:</span></b> Tuesday, September =
24, 2002
3:59 PM<br>
<b><span style=3D'font-weight:bold'>To:</span></b> Chris A. Bruce; =
zope@zope.org<br>
<b><span style=3D'font-weight:bold'>Subject:</span></b> RE: [Zope] =
Passing
Arguments to ZSQL Method from Python Script</span></font></p>

<p class=3DMsoNormal style=3D'margin-left:.5in'><font size=3D3 =
face=3D"Times New Roman"><span
style=3D'font-size:12.0pt'>&nbsp;</span></font></p>

<p style=3D'margin-left:.5in'><font size=3D2 face=3D"Times New =
Roman"><span
style=3D'font-size:10.0pt'>Would something like this work:</span></font> =
</p>

<p style=3D'margin-left:.5in'><font size=3D2 face=3D"Times New =
Roman"><span
style=3D'font-size:10.0pt'>for user in
context.Users.RegistrationInfo.objectValues(&quot;UserInfo&quot;):</span>=
</font>
<br>
<font size=3D2><span style=3D'font-size:10.0pt'>&nbsp; =
context.sql_users_insert(first_name=3Duser.first_name,
last_name=3Duser.last_name, etc.)</span></font> </p>

<p style=3D'margin-left:.5in'><font size=3D2 face=3D"Times New =
Roman"><span
style=3D'font-size:10.0pt'>if user is a dictionary, the zsql arguments =
would be
first_name=3Duser[first_name], last_name=3Duser[last_name], =
etc.</span></font> </p>

<p style=3D'margin-left:.5in'><font size=3D2 face=3D"Times New =
Roman"><span
style=3D'font-size:10.0pt'>-Scott</span></font> </p>

<p style=3D'margin-left:.5in'><font size=3D2 face=3D"Times New =
Roman"><span
style=3D'font-size:10.0pt'>-----Original Message-----</span></font> <br>
<font size=3D2><span style=3D'font-size:10.0pt'>From: Chris A. Bruce [<a
href=3D"mailto:cbruce@sleeter.com">mailto:cbruce@sleeter.com</a>]</span><=
/font> <br>
<font size=3D2><span style=3D'font-size:10.0pt'>Sent: Tuesday, September =
24, 2002
3:36 PM</span></font> <br>
<font size=3D2><span style=3D'font-size:10.0pt'>To: =
zope@zope.org</span></font> <br>
<font size=3D2><span style=3D'font-size:10.0pt'>Subject: [Zope] Passing =
Arguments
to ZSQL Method from Python Script</span></font> </p>

<p class=3DMsoNormal style=3D'margin-left:.5in'><font size=3D3 =
face=3D"Times New Roman"><span
style=3D'font-size:12.0pt'>&nbsp;</span></font></p>

<p style=3D'margin-left:.5in'><font size=3D2 face=3D"Times New =
Roman"><span
style=3D'font-size:10.0pt'>Is there an easy way to bind the attributes =
of an object
into the parameters of a zsql method?&nbsp; I am trying to do something =
like
this in Python Script:</span></font></p>

<p style=3D'margin-left:.5in'><font size=3D2 face=3D"Times New =
Roman"><span
style=3D'font-size:10.0pt'>for user in
context.Users.RegistrationInfo.objectValues(&quot;UserInfo&quot;):</span>=
</font>
<br>
<font size=3D2><span style=3D'font-size:10.0pt'>&nbsp;
context.sql_users_insert(user)</span></font> </p>

<p style=3D'margin-left:.5in'><font size=3D2 face=3D"Times New =
Roman"><span
style=3D'font-size:10.0pt'>The sql_users_insert takes a bunch of =
parameters and
the &quot;user&quot; object above is a ZClass with properties that have =
exact
names as parameters for zsql method.</span></font></p>

<p class=3DMsoNormal =
style=3D'margin-right:0in;margin-bottom:12.0pt;margin-left:
.5in'><font size=3D3 face=3D"Times New Roman"><span =
style=3D'font-size:12.0pt'>&nbsp;</span></font></p>

<p style=3D'margin-left:.5in'><font size=3D2 face=3D"Times New =
Roman"><span
style=3D'font-size:10.0pt'>Thanks for any help,</span></font> </p>

<p class=3DMsoNormal style=3D'margin-left:.5in'><font size=3D3 =
face=3D"Times New Roman"><span
style=3D'font-size:12.0pt'>&nbsp;</span></font></p>

<p style=3D'margin-left:.5in'><font size=3D2 face=3D"Times New =
Roman"><span
style=3D'font-size:10.0pt'>Chris Bruce</span></font> <br>
<font size=3D2><span style=3D'font-size:10.0pt'>The information =
contained in this
email message may be privileged and is confidential information intended =
only
for the use of the recipient or any employee or agent responsible for
delivering it to the intended recipient.&nbsp; Any unauthorized use,
distribution or copying of this information is strictly prohibited and =
may be
unlawful.&nbsp; If you have received this communication in error, please =
notify
the sender immediately and destroy the original message and all =
attachments
from your electronic files.</span></font></p>

</div>

</body>

</html>
=00
------_=_NextPart_001_01C26420.6DAD1FE0--