Providing Arguments to ZSQL Methods that Insert and Update in Python
Dear Zenith of Zope Knowledge, Thanks for all the help from before it is truly appreciated. I know that it's possible to provide arguments when selecing in a ZSQL Method, but is it possible to provide arguments to UPDATE and INSERT. I'll use an example that I found from a previous entry in the Zope mailing list. The ZSQL method looks like this: Arguments: emp_id first last salary UPDATE person SET person_first_name = first, person_last_name = last, person_salary = salary WHERE person_emp_id = emp_id and the call in the Script(Python) would be: (context.aq_parent).updates.update_person(empid=someval1, first=someval2, last=someval3, salary=someval4) I'm having trouble correlating the Python variables with the ones in the ZSQL method. I know how to pass variables from forms in DTML documents via <dtml-sqlvar emp_id type=string>. Any help would be appreciated. Thanks in advance and have a great weekend! Take care, Muk Yan
--On 6. August 2006 14:45:53 -0400 Muk Yan <myan@umich.edu> wrote:
Dear Zenith of Zope Knowledge,
Thanks for all the help from before it is truly appreciated.
I know that it's possible to provide arguments when selecing in a ZSQL Method, but is it possible to provide arguments to UPDATE and INSERT.
This question makes little sense to me. See below.
I'm having trouble correlating the Python variables with the ones in the ZSQL method. I know how to pass variables from forms in DTML documents via <dtml-sqlvar emp_id type=string>. Any help would be appreciated. Thanks in advance and have a great weekend!
Since <dtml-sqlvar..> is used to generate "dynamic" SQL it really does not matter if this method is an insert, update or whatever method. In fact ZSQL know nothing about insert, update or select. Easily said: <dtml-sqlvar ...> performs a textual replacement in any sql context. -aj
Thanks Andreas, sorry about the confusion. What I want to do is call the ZSQL Method from a Python script instead of from a DTML Document or Method. I want to know if there's a way to provide arguments from the Python Script to ZSQL Methods with Updates and Inserts. This is just a toy problem: Arguments: emp_id first last salary UPDATE person SET person_first_name = first, person_last_name = last, person_salary = salary WHERE person_emp_id = emp_id (context.aq_parent).updates.update_person(empid=someval1, first=someval2, last=someval3, salary=someval4) I want to avoid using <dtml-sqlvar emp_id type=string>. Thanks again. Peace and take care, Muk
--On 6. August 2006 15:13:33 -0400 Muk Yan <myan@umich.edu> wrote:
Thanks Andreas, sorry about the confusion.
What I want to do is call the ZSQL Method from a Python script instead of from a DTML Document or Method. I want to know if there's a way to provide arguments from the Python Script to ZSQL Methods with Updates and Inserts.
I want to avoid using <dtml-sqlvar emp_id type=string>.
Huh? <dtml-sqlvar...> is only used inside the *ZSQL* method. A ZSQL method is a first-class object in Zope and can be called from DTMl, PythonScripts, ZPT, external methods, filesystem code ... an object is an object is an object ....and can be called from always basically in the same way...so where is the problem? -aj
Thanks Andreas, I think I get it now after getting it spoon fed to me from Roberto (which I greatly appreciate). Thanks all and have a great rest of the weekend for tomorrow is Monday. Peace and take care, Muk Yan On 8/6/06, Andreas Jung <lists@zopyx.com> wrote:
--On 6. August 2006 15:13:33 -0400 Muk Yan <myan@umich.edu> wrote:
Thanks Andreas, sorry about the confusion.
What I want to do is call the ZSQL Method from a Python script instead of from a DTML Document or Method. I want to know if there's a way to provide arguments from the Python Script to ZSQL Methods with Updates and Inserts.
I want to avoid using <dtml-sqlvar emp_id type=string>.
Huh? <dtml-sqlvar...> is only used inside the *ZSQL* method. A ZSQL method is a first-class object in Zope and can be called from DTMl, PythonScripts, ZPT, external methods, filesystem code ... an object is an object is an object ....and can be called from always basically in the same way...so where is the problem?
-aj
participants (2)
-
Andreas Jung -
Muk Yan