Non-query SQL with Zope (naive question)
Hi all... I'm just discovering Zope, have installed v1.10.3 on Linux, am using Zserver for the http server, and am using PostGreSQL with ZPyGreSQLDA. I was happily developing my web site, including creating queries of a PostGres DB, when I found that I could not create insert, update, or deletion SQL commands. The docs support this fact, but I can't believe that people have not wanted to do more SQL beyond just querying. I'm guessing that I could write some Python extensions to do that sort of thing, but I'm not a Python programmer and I have to believe that someone else wants to do this and is working on it already. I imagine the features of the SQLMethods included with Zope would be as useful in non-query SQL as they are in querying. I haven't delved into v2 and the ZClasses that are available there. Looking at the contributed Products for v1 on the Zope site, I could not see anything that addressed this. Update: I found sqlinputwix1.0.tar.gz, which from the name I can only hope is what I want, but it is MySQL only. I haven't tried setting up a MySQL DB just to see what functionality is provided by this Product. How do people make full-fledged web applications with DB back ends using Zope? Or do they even try? How does one get information about the contributed Products without actually installing and tryinig them out? Cheers... Bruce -- Bruce Elrick, Ph.D. Saltus Technology Consulting Group Cell: (403) 870-4429 Personal: belrick@home.com IBM Certified Specialist Business: belrick@saltus.ab.ca ADSM, AIX Support, RS/6000 SP, HACMP
At 06:15 24/08/99 , Bruce Elrick wrote:
Hi all...
I'm just discovering Zope, have installed v1.10.3 on Linux, am using Zserver for the http server, and am using PostGreSQL with ZPyGreSQLDA.
I was happily developing my web site, including creating queries of a PostGres DB, when I found that I could not create insert, update, or deletion SQL commands.
The docs support this fact, but I can't believe that people have not wanted to do more SQL beyond just querying. I'm guessing that I could write some Python extensions to do that sort of thing, but I'm not a Python programmer and I have to believe that someone else wants to do this and is working on it already. I imagine the features of the SQLMethods included with Zope would be as useful in non-query SQL as they are in querying.
I haven't delved into v2 and the ZClasses that are available there. Looking at the contributed Products for v1 on the Zope site, I could not see anything that addressed this. Update: I found sqlinputwix1.0.tar.gz, which from the name I can only hope is what I want, but it is MySQL only. I haven't tried setting up a MySQL DB just to see what functionality is provided by this Product.
How do people make full-fledged web applications with DB back ends using Zope? Or do they even try?
What problems have you run into when you tried? ZSQL methods support all SQL your database supports, including updates, inserts and deletes. When I install a Zope server elsewhere, that uses a database, I include the table create statements as well. Just run one DTML method, and the whole database is set up. The MySQL SQL Input Wizard just creates a few DTML Methods for you, to use as an example when developing your own inserts and updates. It uses some non-standardized features of the ZMySQLDA to query table and column definitions. You don't need it to enable database manipulation. When you create a ZSQL method, first use it's Test tab to see if your SQL works. Then you can start calling the method from your DTML. Remember to put any parameters you want to pass into the SQL Method in the 'Arguments' field. Now, if you have a method called 'insertNewContact' with arguments 'name:required' and 'email' and the following SQL: insert into contacts values (<!--#sqlvar name type=string-->, <!--#sqlvar email type=string optional-->) you can call this from DTML with: <!--#call "insertNewContact(name='Martijn Pieters', email='mj@antraciet.nl')"--> or you can put the parameters in the REQUEST object: <!--#call "REQUEST.set('name', 'Martijn Pieters')"--> <!--#call "REQUEST.set('email', 'mj@antraciet.nl')"--> <!--#call insertNewContact--> This works the same for updates and deletes, or any other SQL. -- Martijn Pieters, Web Developer | Antraciet http://www.antraciet.nl | Tel: +31-35-7502100 Fax: +31-35-7502111 | mailto:mj@antraciet.nl http://www.antraciet.nl/~mj | PGP: http://wwwkeys.nl.pgp.net:11371/pks/lookup?op=get&search=0xA8A32149 ------------------------------------------
Martijn Pieters wrote:
What problems have you run into when you tried?
ZSQL methods support all SQL your database supports, including updates, inserts and deletes. When I install a Zope server elsewhere, that uses a database, I include the table create statements as well. Just run one DTML method, and the whole database is set up.
... Thanks Martijn... It would appear that I was too quick to think I failed. When you test the output screen states the "This is not a query". After getting errors earlier due to malformed SQL, I assumed this was an error too. I was expecting something along the lines of what the command line would give, like "Inserted 1", indicating that I was successful. Live and learn. Thanks again for clearing that up. By the way, in your message you showed this way of calling the SQL Method: <!--#call "insertNewContact(name='Martijn Pieters', email='mj@antraciet.nl')"--> Is that equivalent to the browser doing http://site.com/path/to/method/insertNewContact?name=Matin+Pieters?email=mj@... when you create a form that has the method as an action? Cheers... Bruce -- Bruce Elrick, Ph.D. Saltus Technology Consulting Group Cell: (403) 870-4429 Personal: belrick@home.com IBM Certified Specialist Business: belrick@saltus.ab.ca ADSM, AIX Support, RS/6000 SP, HACMP
At 16:49 24-8-99 , Bruce Elrick wrote:
By the way, in your message you showed this way of calling the SQL Method:
<!--#call "insertNewContact(name='Martijn Pieters', email='mj@antraciet.nl')"-->
Is that equivalent to the browser doing http://site.com/path/to/method/insertNewContact?name=Matin+Pieters?email=mj@ antraciet.nl
No, but the REQUEST.set does do the same. You would do better setting the target of the form to a DTML Method that does the call to your SQL method, because that way you can give custom feedback. Let's assume you still have that you still have the insertNewContact method. Now you also have a insertNewContactForm DTML Document: <!--#var standard_html_header--> <FORM ACTION=insertNewContactAction> <INPUT TYPE=text NAME=name> <INPUT TYPE=text NAME=email> <INPUT TYPE=submit> </FORM> <!--#var standard_html_footer--> and you have a insertNewContactAction DTML Method: <!--#var standard_html_header--> <!--#call insertNewContact--> New contact has been added to the database. <!--#var standard_html_footer--> -- Martijn Pieters, Web Developer | Antraciet http://www.antraciet.nl | T: +31 35 7502100 F: +31 35 7502111 | mj@antraciet.nl http://www.antraciet.nl/~mj | PGP: http://wwwkeys.nl.pgp.net:11371/pks/lookup?op=get&search=0xA8A32149 ---------------------------------------------
Thanks Martijn... The following gives me a good framework to work from. Cheers... Bruce Martijn Pieters wrote:
At 16:49 24-8-99 , Bruce Elrick wrote:
By the way, in your message you showed this way of calling the SQL Method:
<!--#call "insertNewContact(name='Martijn Pieters', email='mj@antraciet.nl')"-->
Is that equivalent to the browser doing http://site.com/path/to/method/insertNewContact?name=Matin+Pieters?email=mj@ antraciet.nl
No, but the REQUEST.set does do the same.
You would do better setting the target of the form to a DTML Method that does the call to your SQL method, because that way you can give custom feedback.
Let's assume you still have that you still have the insertNewContact method.
Now you also have a insertNewContactForm DTML Document:
<!--#var standard_html_header--> <FORM ACTION=insertNewContactAction> <INPUT TYPE=text NAME=name> <INPUT TYPE=text NAME=email> <INPUT TYPE=submit> </FORM> <!--#var standard_html_footer-->
and you have a insertNewContactAction DTML Method:
<!--#var standard_html_header--> <!--#call insertNewContact--> New contact has been added to the database. <!--#var standard_html_footer-->
-- Martijn Pieters, Web Developer | Antraciet http://www.antraciet.nl | T: +31 35 7502100 F: +31 35 7502111 | mj@antraciet.nl http://www.antraciet.nl/~mj | PGP: http://wwwkeys.nl.pgp.net:11371/pks/lookup?op=get&search=0xA8A32149 ---------------------------------------------
-- Bruce Elrick, Ph.D. Saltus Technology Consulting Group Cell: (403) 870-4429 Personal: belrick@home.com IBM Certified Specialist Business: belrick@saltus.ab.ca ADSM, AIX Support, RS/6000 SP, HACMP
On Tue, Aug 24, 1999 at 09:57:36AM +0200, Martijn Pieters wrote:
At 06:15 24/08/99 , Bruce Elrick wrote:
Hi all...
<tale of woe with inserts, etc.>
How do people make full-fledged web applications with DB back ends using Zope? Or do they even try?
What problems have you run into when you tried?
<Martijn's description of how he uses Zope with a DB>
When you create a ZSQL method, first use it's Test tab to see if your SQL works. Then you can start calling the method from your DTML. Remember to put any parameters you want to pass into the SQL Method in the 'Arguments' field.
Here's the rub, Martijn. I bet when Bruce ran into the fact that when you use the test tab on a ZSQL method that does not have select in it (i.e., it returns nothing) you get a very misleading message, implying an error. I remember being confused by it the first time I saw it, as well. Bruce, just check the DB via other methods (psql command prompt, or set PGDEBUG to 3, restart the postmaster and watch you logs) You'll see that all your non-select ZSQL works just fine. THT, Ross -- Ross J. Reedstrom, Ph.D., <reedstrm@rice.edu> NSBRI Research Scientist/Programmer Computer and Information Technology Institute Rice University, 6100 S. Main St., Houston, TX 77005
participants (3)
-
Bruce Elrick -
Martijn Pieters -
Ross J. Reedstrom