Re: [Zope] passing the parameters to zsql method
Dario Lopez-Kästen wrote: > Jean-Marc Orliaguet wrote: > >> Dario Lopez-Kästen wrote: >> >> >> >>> 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? >>> >> >> >> Just curious too: isn't there an easier way of doing this using schemas >> / widgets / SQL adapters? >> >> or are the zsql scripts so very specific that they do more than simple >> schema mappings? >> >> >> > all of this sound way more complex that 1 script, 1 zpt and 1 zsql... > sure, but I meant to avoid duplicating code. The 1 script, 1 zpt and 1 zsql guys are really one-trick ponies. /JM ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
Re: [Zope] passing the parameters to zsql method
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: ... The report basically starts with: 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 signature.asc Description: Digital signature ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
Re: [Zope] passing the parameters to zsql method
Jean-Marc Orliaguet wrote: Dario Lopez-Kästen wrote: 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? Just curious too: isn't there an easier way of doing this using schemas / widgets / SQL adapters? or are the zsql scripts so very specific that they do more than simple schema mappings? all of this sound way more complex that 1 script, 1 zpt and 1 zsql... also you might want to put that logic in a tool and protect the methods? (scripts and ZPTs are not protected as far as I know) se above... of course, IMHO, my 2 eurocents worth, YMMV, Standard Disclaimers Apply, etc. /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 ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
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: [EMAIL PROTECTED] 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): tal:omit-tag="" /> 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 ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
Re: [Zope] passing the parameters to zsql method
Denis V. Gudtsov wrote: clients_add_sql: insert into table(name,account) values (, ); the problem is when i click the 'submit' button, the form "clients_add_sql Input Data Enter query parameters:" appears. Does someone know how i can pass the form parameters to zsql method directly? use an intermediary Script (Python), ie: --- # extract data from form and put into zsql-method. request = continer.REQUEST name = request.form.get('name', None) account = request.form.get('account', None) # Sanity check - do we have values? if name and account: # assume that the zsql-method is in the same folder as this script container.clients_add_sql(name=name, account=account) # if the zsql is not in the same folder as this script, use aquisition #context.clients_add_sql(name=name, account=account) --- As you can see, introducing a script in between has other benefits as well, such as allowing for data verification etc. to call the script change: to hope this helps. /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 ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
[Zope] passing the parameters to zsql method
Hello! I'm trying to pass the form parameters from page template to zsql method. A piece of code follows: clients_add_sql: insert into table(name,account) values (, ); the problem is when i click the 'submit' button, the form "clients_add_sql Input Data Enter query parameters:" appears. Does someone know how i can pass the form parameters to zsql method directly? -- ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )