Need help with ':records' form construct
Hello, I'm hoping that one of you can help me out with the not-very-well-documented ' :records ' form construct. I have a long form which contains information from around 100 separate database records.. This is being sent into Zope from a FileMaker form.. Its displayed in a long Zope form (it displays properly...) and edited.. and then I'm hoping to submit it from Zope and use the information to populate a SQL database via a ZSQL method.. I've tried two different ways to get it into my database, both iterating through the results and calling the SQL method on each iteration, and also doing my dtml-in in the ZSQL method itself. Neither have worked.. The ZSQL documentation doesn't give much to go on.... so I'm hoping some of you can give me some pointers.. The data is mixed strings and integer data, but that shouldnt be a problem.. When I point the forms action at a method with simply <dtml-var REQUEST> in it, I see that it appears that the data is being concatenated together.. Is this what is supposed to be happening? Any ideas or suggestions on how to make this work are welcome.. -Chris This is the first part of the form and then the <dtml-var REQUEST> output.. ___cut here________ <input type="hidden" NAME="sqlinput.PERS_FMPID:records" value="&dtml-PERS_FMPID;"> <TR><TD ALIGN="RIGHT">Last Name</TD><TD><INPUT TYPE="TEXT" NAME="sqlinput.PERS_LNAME:records" value="&dtml-PERS_LNAME;"></TD></TR> <TR><TD ALIGN="RIGHT">First Name</TD><TD><INPUT TYPE="TEXT" NAME="sqlinput.PERS_FNAME:records" value="&dtml-PERS_FNAME;"></TD></TR> <TR><TD ALIGN="RIGHT">Person Type</TD><TD> submit Process sqlinput [PERS_AFFILIATION: , PERS_ARRIVALDATE: , PERS_DEPARTDATE: , PERS_EMAIL: alperin, PERS_FMPID: 33133, PERS_FNAME: Roger, PERS_LNAME: Alperin, PERS_OFFICE: , PERS_TYPE: gm, PERS_AFFILIATION: , PERS_ARRIVALDATE: , PERS_DEPARTDATE: , PERS_EMAIL: andersen, PERS_FMPID: 33179, PERS_FNAME: Jorgen, PERS_LNAME: Andersen, P
Somewhere there is some decent documentation but I dont have that ref handy at the moment. The way I understand the records to work is this: In the form, your input tages need to be as so: <input type="text" name="item.a:records:required"> - required bit is superfluous. In the the dtml, you need to call the ZSQL method.... <dtml-if "REQUEST.has_key('Submit')"> <dtml-call submitFormZSQLMethod> </dtml-if> - note there are no parameters passed through this... It doesnt seem to work if you do that... I've tried with no success. In the submitFormZSQLMethod... The parameters passed in are : item:records then the ZSQL method: <dtml-in item> insert into table yaddayadda (a, b, c) values ( <dtml-sqlvar a type=string>, <dtml-sqlvar b type=string>, <dtml-sqlvar c type=string> ) <dtml-var sql_delimiter> </dtml-in> - you are naming all inputs as an class called 'item', and specifiying that they are 'records'. You need the dtml-in because 'records' implies of course more than one, so the REQUEST will show item.a = something item.b = something else and so on - I dont know if you can do this from a Filemaker form because I don't see how the item iteration would work into the Zope namespace... .but Im not the one top ask about that. ... I;m only showing what I know, which aint that much... Paz -----Original Message----- From: zope-admin@zope.org [mailto:zope-admin@zope.org]On Behalf Of Chris Beaumont Sent: Sunday, April 15, 2001 10:49 AM To: zope@zope.org Subject: [Zope] Need help with ':records' form construct Hello, I'm hoping that one of you can help me out with the not-very-well-documented ' :records ' form construct. I have a long form which contains information from around 100 separate database records.. This is being sent into Zope from a FileMaker form.. Its displayed in a long Zope form (it displays properly...) and edited.. and then I'm hoping to submit it from Zope and use the information to populate a SQL database via a ZSQL method.. I've tried two different ways to get it into my database, both iterating through the results and calling the SQL method on each iteration, and also doing my dtml-in in the ZSQL method itself. Neither have worked.. The ZSQL documentation doesn't give much to go on.... so I'm hoping some of you can give me some pointers.. The data is mixed strings and integer data, but that shouldnt be a problem.. When I point the forms action at a method with simply <dtml-var REQUEST> in it, I see that it appears that the data is being concatenated together.. Is this what is supposed to be happening? Any ideas or suggestions on how to make this work are welcome.. -Chris This is the first part of the form and then the <dtml-var REQUEST> output.. ___cut here________ <input type="hidden" NAME="sqlinput.PERS_FMPID:records" value="&dtml-PERS_FMPID;"> <TR><TD ALIGN="RIGHT">Last Name</TD><TD><INPUT TYPE="TEXT" NAME="sqlinput.PERS_LNAME:records" value="&dtml-PERS_LNAME;"></TD></TR> <TR><TD ALIGN="RIGHT">First Name</TD><TD><INPUT TYPE="TEXT" NAME="sqlinput.PERS_FNAME:records" value="&dtml-PERS_FNAME;"></TD></TR> <TR><TD ALIGN="RIGHT">Person Type</TD><TD> submit Process sqlinput [PERS_AFFILIATION: , PERS_ARRIVALDATE: , PERS_DEPARTDATE: , PERS_EMAIL: alperin, PERS_FMPID: 33133, PERS_FNAME: Roger, PERS_LNAME: Alperin, PERS_OFFICE: , PERS_TYPE: gm, PERS_AFFILIATION: , PERS_ARRIVALDATE: , PERS_DEPARTDATE: , PERS_EMAIL: andersen, PERS_FMPID: 33179, PERS_FNAME: Jorgen, PERS_LNAME: Andersen, P _______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
You need to do two things: 1) Start SIMPLE - create something tiny in Filemaker, and learn how to get it working first. 2) Give us something useful to think about. You have said the equivalent of "My car doesn't work. I tried to start it two different ways. What's wrong with it?" Looking at the form data using <dtml-var REQUEST> is the right idea, but it's better to use <dtml-var "REQUEST.form">. One thing that can cause problems, I have found, is this. If you have an HTML form that has several fields with the same name - as you might get with an automatically-generated form - the form returns them all in a list of the same name. That is, a variable personid might be returned as personid:['23','64'] if there were two personid fields in the form. But if there is only one, the form returns personid:23 which is not a list. <dtml-in> does not work with the second example, since there is no list to interate over. You have to test the length of the form variable to find out whether to use <dtml-in>. Another complication is that you can get the form variables two ways: 1) "REQUEST.personid" 2) "REQUEST.form['personid']" These two expressions are NOT the same! I have found that the first gives you a string, not a list, and you can't iterate over it, even though it looks just like a list when you render it. To use <dtml-in>, you must use form 2). I have no idea why, but I spent a lot of time recently wrestling with exactly this quirk. I don't know what your problems are, but these two points helped me a lot. Cheers, Tom P Chris Beaumont asked -
I have a long form which contains information from around 100 separate database records..
This is being sent into Zope from a FileMaker form.. Its displayed in a long Zope form (it displays properly...) and edited.. and then I'm hoping to submit it from Zope and use the information to populate a SQL database via a ZSQL method.. I've tried two different ways to get it into my database, both iterating through the results and calling the SQL method on each iteration, and also doing my dtml-in in the ZSQL method itself. Neither have worked..
"Thomas B. Passin" wrote:
One thing that can cause problems, I have found, is this. If you have an HTML form that has several fields with the same name - as you might get with an automatically-generated form - the form returns them all in a list of the same name. That is, a variable personid might be returned as
personid:['23','64']
if there were two personid fields in the form. But if there is only one, the form returns
personid:23
You can prevent this problem by using personid:list so REQUEST will contain (using your examples): ['23','64'] or ['23'] See: http://www.zope.org/Members/Zen/howto/FormVariableTypes -- Tim Cook, President - FreePM,Inc. http://www.FreePM.com Office: (731) 884-4126 ONLINE DEMO: http://www.freepm.org:8080/FreePM
participants (4)
-
Chris Beaumont -
Paz -
Thomas B. Passin -
Tim Cook