sql SELECT from a list - Beginner's Question
I have a sql table which has 2 columns, v1 and v2. v1 is unique. I want to allow the user to enter up to 50 or less possible v1's, of their own choosing, and then simply view them. So the form page would have entries for up to 50 entry requests for v1. However, they may enter only 25, 30, 40, whatever they would like. So the sql without zope, if there were only 3 records requested, might look like: SELECT v1, v2, FROM tablename WHERE v1='1' or v1='3' or v1='5'; How do I build the form, sql method, and return list to accomplish this? I'm sure this has been done, so if someone could point me to a HOWTO or an example, it would be greatly appreciated. --Thanks.
I think you want to get the values returned from your form into a list and then pass that list to a sql method as an "in list" rather than a series of "or" statements. You'll probably get much better performance out of it as well. The key is to get the html form to pass a "list" which can be done in a couple of ways depending on how you want to set up the form. <form action="parse_my_list"> <dtml-in sel_all_values> <input type=checkbox name=foo:list value="v1"><dtml-var v1><br> </dtml-in> <input type="submit"> </form>
create a zsql method named sel_all_values
arguments: none select * from table_name
should return v1 and v2
parse_my_list in this example is a dtml-method the dtml method calls the zsqlmethod sel_from_list and passes the list of values that are contained in the attribute foo <dtml-in sel_from_list> <dtml-var id> </dtml-in>
create a zsql method named sel_from list sel_from_list
arguments: foo select * from table_name where <dtml-sqltest foo column_name=v1 type=nb multiple> The sqltest operator is a zope specific piece of vodoo that will magically convert the returned values to an in list if more than one are recieved. Hope this helps Todd ----- Original Message ----- From: Herring, William O. <WHerring@mail.ifas.ufl.edu> To: <zope@zope.org> Sent: Saturday, December 15, 2001 8:43 AM Subject: [Zope] sql SELECT from a list - Beginner's Question
I have a sql table which has 2 columns, v1 and v2. v1 is unique. I want to allow the user to enter up to 50 or less possible v1's, of their own choosing, and then simply view them. So the form page would have entries for up to 50 entry requests for v1. However, they may enter only 25, 30, 40, whatever they would like. So the sql without zope, if there were only 3 records requested, might look like:
SELECT v1, v2, FROM tablename WHERE v1='1' or v1='3' or v1='5';
How do I build the form, sql method, and return list to accomplish this? I'm sure this has been done, so if someone could point me to a HOWTO or an example, it would be greatly appreciated. --Thanks.
_______________________________________________ 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 )
Is it possible to automatically run an external method every time a file is saved? That is, is there some kind of file where I can say "when you're saved, call this method?"t Most current information can be found at: http://www.mindview.net/Etc/notes.html =================== Bruce Eckel http://www.BruceEckel.com Contains free electronic books: "Thinking in Java 2e" & "Thinking in C++ 2e" Please subscribe to my free newsletter -- just send any email to: join-eckel-oo-programming@earth.lyris.net My schedule can be found at: http://www.mindview.net/Calendar ===================
I think I understand your question: do you mean a file saved to zodb through the webinterface? If so, then try to create your own screen and dtml document to upload your file. Else if you want to circumvent to already provide (by zope.org) classes, then try a hotfix approach. Regards, Luis. ----- Original Message ----- From: "Bruce Eckel" <Bruce@EckelObjects.com> To: <zope@zope.org> Sent: Saturday, December 15, 2001 2:22 PM Subject: [Zope] Automatically run an external method?
Is it possible to automatically run an external method every time a file is saved? That is, is there some kind of file where I can say "when you're saved, call this method?"t
Most current information can be found at: http://www.mindview.net/Etc/notes.html =================== Bruce Eckel http://www.BruceEckel.com Contains free electronic books: "Thinking in Java 2e" & "Thinking in C++ 2e" Please subscribe to my free newsletter -- just send any email to: join-eckel-oo-programming@earth.lyris.net My schedule can be found at: http://www.mindview.net/Calendar ===================
_______________________________________________ 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 )
Yes, a file modified through the web interface and saved to the ZODB. For example, something like a DTML Document. The idea is that the document is a configuration/information file, and the external method will take this and process it to generate an output file. Seems like this could be a useful model in general for solving problems. (input-process-output, triggered by a change in input). *********** REPLY SEPARATOR *********** On 12/15/01 at 2:59 PM zope news wrote:
I think I understand your question: do you mean a file saved to zodb through the webinterface? If so, then try to create your own screen and dtml document to upload your file.
Else if you want to circumvent to already provide (by zope.org) classes, then try a hotfix approach.
Regards, Luis.
----- Original Message ----- From: "Bruce Eckel" <Bruce@EckelObjects.com> To: <zope@zope.org> Sent: Saturday, December 15, 2001 2:22 PM Subject: [Zope] Automatically run an external method?
Is it possible to automatically run an external method every time a file is saved? That is, is there some kind of file where I can say "when you're saved, call this method?"t
Most current information can be found at: http://www.mindview.net/Etc/notes.html =================== Bruce Eckel http://www.BruceEckel.com Contains free electronic books: "Thinking in Java 2e" & "Thinking in C++ 2e" Please subscribe to my free newsletter -- just send any email to: join-eckel-oo-programming@earth.lyris.net My schedule can be found at: http://www.mindview.net/Calendar ===================
_______________________________________________ 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 )
Most current information can be found at: http://www.mindview.net/Etc/notes.html =================== Bruce Eckel http://www.BruceEckel.com Contains free electronic books: "Thinking in Java 2e" & "Thinking in C++ 2e" Please subscribe to my free newsletter -- just send any email to: join-eckel-oo-programming@earth.lyris.net My schedule can be found at: http://www.mindview.net/Calendar ===================
From: "Bruce Eckel" <Bruce@EckelObjects.com>
Yes, a file modified through the web interface and saved to the ZODB. For example, something like a DTML Document.
Ah, I thought you ment the file object.
The idea is that the document is a configuration/information file, and the external method will take this and process it to generate an output file.
There would be no problem writing an object like that. However, if you are talking about getting a call everytime ANY object gets saved it's a bit more complicated.
From: "Bruce Eckel" <Bruce@EckelObjects.com>
Is it possible to automatically run an external method every time a file is saved? That is, is there some kind of file where I can say "when you're saved, call this method?"t
"Saved"? What do you mean? Saved to disk, or uploaded to Zope, or changing the properties?
participants (5)
-
Bruce Eckel -
Herring, William O. -
Lennart Regebro -
Todd Graham -
zope news