Re: [Zope] passing the parameters to zsql method
Denis V. Gudtsov wrote:
DLK> use an intermediary Script (Python), ie: [..skipped..]
Thank you. But, can i do this without using python? From zpt -> to zsql?
[cc-ing: zope@zope.org] well, yes in a way. ZSQL methods have to be called like other metods, but AFAIK, they cannot be traversed like, for instance, scripts. As I understand it, this is for security reasons (I myself would never allow a zsql to be exposed without some scripts in between, but that's just me...) Anyway, one way to do what you want is to do more in the zpt than may be advisable: exactly how to do it, I leave up to you, becasue there are several different ways of achieving this, but I give general directions. Also, there are probably other ways than what I describe below. You can make the form post to iself, and use calls inside the form to prepare the input to the zsql. lets say your zpt is called "entry_form" and looks something like this (pseudo zpt): <span tal:define="name request/form/name; account request/form/account; unused python: clients_add_sql(name=name, account=account);" tal:omit-tag="" /> <form action="entry_form"> <input type="text" name="name"> <input type="text" name="account"> <input type="submit"> </form> Not sure if this works, but that is the general idea. This was inspired from http://www.plope.com/Books/2_7Edition/AdvZPT.stx#2-9 section: "Form Processing" Good luck! /dario -- -- ------------------------------------------------------------------- Dario Lopez-Kästen, IT Systems & Services Chalmers University of Tech. Lyrics applied to programming & application design: "emancipate yourself from mental slavery" - redemption song, b. marley
On Thu, Oct 27, 2005 at 10:23:52AM +0200, Dario Lopez-Kästen wrote:
Not sure if this works, but that is the general idea. This was inspired from
http://www.plope.com/Books/2_7Edition/AdvZPT.stx#2-9
section: "Form Processing"
I would suggest to give it a try with a Z Search Interface. See the same book, in the chapter on Relational Databases: http://www.plope.com/Books/2_7Edition/RelationalDatabases.stx#1-11 This assists you in making two pages, at your choice as either DTML Methods or Page Templates. Like most people here I would suggest going for the Page Templates. One is a form in which you can enter the values for your Z SQL Method. This then passes control to the second page, which is a report that gets its input by calling the Z SQL Method. The form basically is: <form action="<id of your report page" method="get"> ... <input type="SUBMIT" name="SUBMIT" value="Submit Query"> The report basically starts with: <html> <body tal:define="results here/<id of your Z SQL Method>"> Note that when your Z SQL Method only has an update or insert or delete it will usually not return a lot of results, so the report will be basically empty. I would say it is nice if the user gets some feedback, so put some related select statement after your normal query, even if it is just: SELECT * from your_table. This gives the report something to present to the user as visual feedback, instead of leaving him in the dark on whether the submission of the form actually had any permanent results. -- Maurits van Rees | http://maurits.vanrees.org/ [Dutch/Nederlands] Public GnuPG key: http://maurits.vanrees.org/var/gpgkey.asc "It can seem like you're doing just fine, but the creep's creeping into your mind." - Neal Morse
participants (2)
-
Dario Lopez-Kästen -
Maurits van Rees