Data from forms into a database - how?
Hello! Don't laugh at me - this is probably a very simple thing to do, but as I'm new to zope and can't find description of how this is accomplished I seek your help. I get data out of my database (MySQL) by querying, but how can I have data collected by forms showeled into the database? Appreciate any help I can get! Sture Lygren
raver@box.dust.za.net wrote:
Hello!
Don't laugh at me - this is probably a very simple thing to do, but as I'm new to zope and can't find description of how this is accomplished I seek your help. I get data out of my database (MySQL) by querying, but how can I have data collected by forms showeled into the database?
Appreciate any help I can get!
Hi Sture, try to use the P MySQL Input wizard in the contrib download area. It will automatically create a insert sql method and a form for you. So you can just follow the pattern. []s -- Paulo Eduardo Neves PUC-Rio de Janeiro Pager: Central: 292-4499 cod. 213 99 64 ou use a URL: http://www.learn.fplf.org.br/neves/mensagempager.html
raver@box.dust.za.net wrote:
Hello!
Don't laugh at me - this is probably a very simple thing to do, but as I'm new to zope and can't find description of how this is accomplished I seek your help. I get data out of my database (MySQL) by querying, but how can I have data collected by forms showeled into the database?
Appreciate any help I can get!
Hi Sture, try to use the P MySQL Input wizard in the contrib download area. It will automatically create a insert sql method and a form for you. So you can just follow the pattern.
So that is what the MySQL Input wizard does. I've been meaning to look at it. Instead of saving time by using it, I did it manually. It is not that hard but you have to understand what is happening. 1. HTML form (eg. form_html) collects data and sends it to a DTML document (eg input_html) (that is the only tricky concept). For example: <form action="input_html" method="get"> <input name="num:int"> </form> (That :int tag does error checking. It is optional. They are documented in the Z SQL Database Methods User's Guide) 2. The receiving doc (input_html) calls an SQL method (eg input_sql) with an in tag. <!--#in input_sql--> <!--/in--> If you do a select after your INSERT or UPDATE you can use it between the in tags, otherwise you can just display a message or do a redirect after it. 3. Your SQL method (input_sql) would be something like: INSERT INTO database (num) VALUES ( <!--#sqlvar num type=int--> ) <!--#var sql_delimiter--> SELECT num, etc You don't need to do a select but if you do don't forget the <!--#var sql_delimiter--> between any SQL statements. Have fun! Phil A ------------------------------------------ Philip Aylesworth zopelist@regalint.com Regal International
At 15:50 04/03/99 , Philip Aylesworth wrote:
2. The receiving doc (input_html) calls an SQL method (eg input_sql) with an in tag.
<!--#in input_sql--> <!--/in-->
If you do a select after your INSERT or UPDATE you can use it between the in tags, otherwise you can just display a message or do a redirect after it.
If you don't do anything with the returned data, a #call will suffice: <!--#call input_sql--> -- M.J. Pieters, Web Developer | Antraciet http://www.antraciet.nl | Tel: +31-35-6254545 Fax: +31-35-6254555 | mailto:mj@antraciet.nl http://www.antraciet.nl/~mj | PGP: http://wwwkeys.nl.pgp.net:11371/pks/lookup?op=get&search=0xA8A32149 ------------------------------------------
On Thu, Mar 04, 1999 at 04:18:02PM +0100, Martijn Pieters wrote:
At 15:50 04/03/99 , Philip Aylesworth wrote:
2. The receiving doc (input_html) calls an SQL method (eg input_sql) with an in tag.
<!--#in input_sql--> <!--/in-->
If you do a select after your INSERT or UPDATE you can use it between the in tags, otherwise you can just display a message or do a redirect after it.
If you don't do anything with the returned data, a #call will suffice:
<!--#call input_sql-->
-- M.J. Pieters, Web Developer | Antraciet http://www.antraciet.nl | Tel: +31-35-6254545 Fax: +31-35-6254555 | mailto:mj@antraciet.nl http://www.antraciet.nl/~mj | PGP: http://wwwkeys.nl.pgp.net:11371/pks/lookup?op=get&search=0xA8A32149 ------------------------------------------
_______________________________________________ Zope maillist - Zope@zope.org http://www.zope.org/mailman/listinfo/zope
Both answers are much appreciated. Things start to clear up, but ... As far as I understand zope it should also be possible to have forms send data directly to external methods. How do I go abouth to make the argument list in a python function so that it receives more than one 'form variable'. 1 is simple, but my form consists of 5. I get an error constructing the python function to take 5 arguments. How is the 5 'variables' sent to the method? How do I get hold of the values each store? Lotsa questions - probly me doing things the wrong way but - I'm learning:) Sture Lygren
A few days late for this thread, but I just ran into the problem. After reading through the thread, and poking around the MySQLmodule source a bit. I thought I'd see what happened if I changed the unhandled to long in the MySQLmodule... At line 440 in MySQLmodule.c, change 'unhandled to 'long', or as a unified format diff: --- MySQLmodule.c.orig Mon Jan 25 07:33:46 1999 +++ MySQLmodule.c Mon Mar 8 18:48:00 1999 @@ -435,9 +435,11 @@ type = "timestamp"; break; case FIELD_TYPE_NULL: + type = "unhandled" + break; case FIELD_TYPE_LONGLONG: case FIELD_TYPE_INT24: - type = "unhandled"; + type = "long"; break; case FIELD_TYPE_VAR_STRING: type = "varchar"; So far, no problems. --- John Eikenberry [jae@kavi.com - http://taos.kavi.com/~jae/] ______________________________________________________________ "A society that will trade a little liberty for a little order will deserve neither and lose both." --B. Franklin
On Mon, 8 Mar 1999, John Eikenberry wrote:
--- MySQLmodule.c.orig Mon Jan 25 07:33:46 1999 +++ MySQLmodule.c Mon Mar 8 18:48:00 1999 <bad patch snipped>
Ok, I'm stupid. I realized right after I sent this, that I forgot a semicolon... anyways... here's the correct patch. --- MySQLmodule.c.orig Mon Jan 25 07:33:46 1999 +++ MySQLmodule.c Mon Mar 8 18:50:47 1999 @@ -435,9 +435,11 @@ type = "timestamp"; break; case FIELD_TYPE_NULL: + type = "unhandled"; + break; case FIELD_TYPE_LONGLONG: case FIELD_TYPE_INT24: - type = "unhandled"; + type = "long"; break; case FIELD_TYPE_VAR_STRING: type = "varchar"; --- John Eikenberry [jae@kavi.com - http://taos.kavi.com/~jae/] ______________________________________________________________ "A society that will trade a little liberty for a little order will deserve neither and lose both." --B. Franklin
Something I'm just curious about... where <!--#sqltest name column=column_name type=column_type--> VS. where column_name = <!--#var name--> Is the only advantage of using the first (sqltest) the type checking? I can't find any other obvious advantages. --- John Eikenberry [jae@kavi.com - http://taos.kavi.com/~jae/] ______________________________________________________________ "A society that will trade a little liberty for a little order will deserve neither and lose both." --B. Franklin
On Wed, Mar 03, 1999 at 08:22:43PM -0300, Paulo Eduardo Neves wrote:
raver@box.dust.za.net wrote:
Hello!
Don't laugh at me - this is probably a very simple thing to do, but as I'm new to zope and can't find description of how this is accomplished I seek your help. I get data out of my database (MySQL) by querying, but how can I have data collected by forms showeled into the database?
Appreciate any help I can get!
Hi Sture, try to use the P MySQL Input wizard in the contrib download area. It will automatically create a insert sql method and a form for you. So you can just follow the pattern.
Actually just after I sent the mail initially I spottet the Input Wizard at the zope site. It works just great. Thanks!
[]s -- Paulo Eduardo Neves PUC-Rio de Janeiro Pager: Central: 292-4499 cod. 213 99 64 ou use a URL: http://www.learn.fplf.org.br/neves/mensagempager.html
participants (5)
-
John Eikenberry -
Martijn Pieters -
Paulo Eduardo Neves -
Philip Aylesworth -
raver@box.dust.za.net