I am designing a site which will be used for a lot of data entry. I have zope 2.1.2 and mysql talking nicely. Now my problem is design. I want the user to be able to fill in a form using some HTML select fields, these fields should then be translated into their respective item IDs for input into my table. So even though the user chooses: cat dog mouse the sql final method should be: insert into table animals (cID, dID, mID) values (12, 14, 18) In a CGI, I would use a python dictionary or perl hash to translate the keys into their values before makeing. But I'm a little stumped with zope? Should I handle this with an external method or can I do it with straight sql methods and built-ins?
darryl@igor.penguinpowered.com wrote:
I am designing a site which will be used for a lot of data entry. I have zope 2.1.2 and mysql talking nicely. Now my problem is design.
I want the user to be able to fill in a form using some HTML select fields, these fields should then be translated into their respective item IDs for input into my table. So even though the user chooses:
cat dog mouse
the sql final method should be:
insert into table animals (cID, dID, mID) values (12, 14, 18)
In a CGI, I would use a python dictionary or perl hash to translate the keys into their values before makeing. But I'm a little stumped with zope? Should I handle this with an external method or can I do it with straight sql methods and built-ins?
You may want to look at my ZFormulator product. You could make a new field type in it that does this. You can also do it with external methods or even with DTML; you can do things like: REQUEST.set("cID", {'cat': 10, 'dog': 11}[cID]) before you pass REQUEST along to a zsql method. Regards, Martijn
The way I do this: I have a table called lookups that is essentially a dictionary with key-value pairs grouped according to category. For Example: category=animals lookup=12 value=cat category=animals lookup=14 value=dog category=animals lookup=18 value=mouse sql statement "anilookup": select lookup,value from lookups where category='animals' order by value In your form: (field name in data table (not lookup) is anichoice) <dtml-in SqlSelectForCurrentDataRecord> <select name="anichoice" size =1> <option value=0 <dtml-if "anichoice==0">selected</dtml-in>>None Selected</option> <dtml-in anilookup> <option value="<dtml-var lookup>" <dtml-if "anichoice==lookup">selected</dtml-in>><dtml-var value></option> </dtml-in> </select> </dtml-in> __________________________________________________________________ Jim Sanford . Database Engineer / \ / Accelerated Technology, Inc. / / 720 Oak Circle Drive East / / \ Mobile, AL 36609 / / \ Voice: 334-661-5770 fax: 334-661-5788 / \ E-Mail: jsanford@atinucleus.com Web: http://www.atinucleus.com Source Code, No Royalties, Any CPU...It just make sense ! __________________________________________________________________ ----- Original Message ----- From: Martijn Faassen <faassen@vet.uu.nl> To: <darryl@igor.penguinpowered.com> Cc: <zope@zope.org> Sent: Friday, January 07, 2000 3:48 PM Subject: Re: [Zope] Zope and Data Entry darryl@igor.penguinpowered.com wrote:
I am designing a site which will be used for a lot of data entry. I have zope 2.1.2 and mysql talking nicely. Now my problem is design.
I want the user to be able to fill in a form using some HTML select fields, these fields should then be translated into their respective item IDs for input into my table. So even though the user chooses:
cat dog mouse
the sql final method should be:
insert into table animals (cID, dID, mID) values (12, 14, 18)
In a CGI, I would use a python dictionary or perl hash to translate the keys into their values before makeing. But I'm a little stumped with zope? Should I handle this with an external method or can I do it with straight sql methods and built-ins?
You may want to look at my ZFormulator product. You could make a new field type in it that does this. You can also do it with external methods or even with DTML; you can do things like: REQUEST.set("cID", {'cat': 10, 'dog': 11}[cID]) before you pass REQUEST along to a zsql method. Regards, Martijn _______________________________________________ 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 )
Why not just do it with JavaScript? Something like <select name='animal1'> <option value='12'>Cat <option value='24'>Dog <option value='31'>Elephant </select> When you return the form to Zope the numbers in the 'value' will be used rather than the textual ones so if the user picked Dog the form would return 24. HTH Phil phil.harris@zope.co.uk ----- Original Message ----- From: <darryl@igor.penguinpowered.com> To: <zope@zope.org> Sent: Friday, January 07, 2000 8:09 PM Subject: [Zope] Zope and Data Entry
I am designing a site which will be used for a lot of data entry. I have zope 2.1.2 and mysql talking nicely. Now my problem is design.
I want the user to be able to fill in a form using some HTML select fields, these fields should then be translated into their respective item IDs for input into my table. So even though the user chooses:
cat dog mouse
the sql final method should be:
insert into table animals (cID, dID, mID) values (12, 14, 18)
In a CGI, I would use a python dictionary or perl hash to translate the keys into their values before makeing. But I'm a little stumped with zope? Should I handle this with an external method or can I do it with straight sql methods and built-ins?
_______________________________________________ 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 )
darryl@igor.penguinpowered.com wrote:
I am designing a site which will be used for a lot of data entry. I have zope 2.1.2 and mysql talking nicely. Now my problem is design.
I want the user to be able to fill in a form using some HTML select fields, these fields should then be translated into their respective item IDs for input into my table. So even though the user chooses:
cat dog mouse
the sql final method should be:
insert into table animals (cID, dID, mID) values (12, 14, 18)
In a CGI, I would use a python dictionary or perl hash to translate the keys into their values before makeing. But I'm a little stumped with zope? Should I handle this with an external method or can I do it with straight sql methods and built-ins?
<CUT> I might not understand your question right, but can't you just use the value attribute of the OPTION element in html (the OPTION element used with SELECT and the one you probably is using at the moment)? (http://www.w3.org/TR/1999/REC-html401-19991224/interact/forms.html#h-17.6). Then return selections as a list:int all the way into a ZSQL Method which takes list:int as argument. Sorry to step on your toes if I'm talking down to you. -- Best regards / Mvh., Steen Suder, sysadm kollegie6400.dk -|- OpenSource --- Sign of the time Scan-Aqua ADVARSEL WARNING http://www.uk.k64.dk/sfs/Scan-Aqua/
participants (5)
-
darryl@igor.penguinpowered.com -
Jim Sanford -
Martijn Faassen -
Phil Harris -
Steen Suder