Hello, How can I perform a "OR" search on a SQL database field using a web form ? E.g. : I have a SQL database table with fields "name", "surname" and the following records: Jimmy Carter Ronald Reagan George Bush Bill Clinton I would like to search the "name" field through a web form and write : George OR Jimmy And it should return : Jimmy Carter George Bush Thanks for your help. Fabrizio C.
Fabrizio writes:
How can I perform a "OR" search on a SQL database field using a web form ? ... Thanks for your help. Hmm....
What have you already looked at? * an SQL description? * the DTML reference? * the Zope book? * the HTML spec or a book about HTML? * URL:http://www.dieter.handshake.de/pyprojects/zope/book/chap3.html I think, you should look at some of them. I would call that doing your homework... Some hints: * you need to decide how to collect the OR operands on the web page. Options: - a multiple selection (be sure to add ":list" to the select name) - a textarea with a ":lines" suffix - an input field with the ':tokens' suffix - a string with 'OR' operators With the exception of the last option, all will give you a list. For the last option, you must parse the string into a list. If things are simple, you could use "string.split". * you now have a list of search terms. The best way to use it in the SQL statement would probably be "dtml-sqltest multiple". See the DTML reference for details * you will need a Z SQL Method and a Database adapter. Thinks, you learn in the Zope book. Be seeing you after your homework with more concrete questions.... Dieter
Thanks for your help, but I still do not get it (although I did do some of the "homework" :-)). This is my Zsql method's DTML: select * from presidents where <dtml-sqltest name type=string multiple> I am using it just from Zope's "test" tab. How do I input a list of names ? Where should I add the :list suffix ? I have read the Zope book and DTML reference, but yet I do not understand. Thanks. Fabrizio C. -----Messaggio Originale----- Da: Dieter Maurer <dieter@handshake.de> A: Fabrizio <facelle@libero.it> Cc: <zope@zope.org> Data invio: lunedì 16 luglio 2001 20.16 Oggetto: Re: [Zope] ZSQL "OR" search help
Fabrizio writes:
How can I perform a "OR" search on a SQL database field using a web form ? ... Thanks for your help. Hmm....
What have you already looked at?
* an SQL description? * the DTML reference? * the Zope book? * the HTML spec or a book about HTML? * URL:http://www.dieter.handshake.de/pyprojects/zope/book/chap3.html
I think, you should look at some of them. I would call that doing your homework...
Some hints:
* you need to decide how to collect the OR operands on the web page. Options:
- a multiple selection (be sure to add ":list" to the select name) - a textarea with a ":lines" suffix - an input field with the ':tokens' suffix - a string with 'OR' operators
With the exception of the last option, all will give you a list. For the last option, you must parse the string into a list. If things are simple, you could use "string.split".
* you now have a list of search terms. The best way to use it in the SQL statement would probably be "dtml-sqltest multiple". See the DTML reference for details
* you will need a Z SQL Method and a Database adapter. Thinks, you learn in the Zope book.
Be seeing you after your homework with more concrete questions....
Dieter
Fabrizio writes:
This is my Zsql method's DTML:
select * from presidents where <dtml-sqltest name type=string multiple>
I am using it just from Zope's "test" tab.
How do I input a list of names ? Where should I add the :list suffix ? It may be that the ":list" suffix does not work (it is known to be broken at least for some Zope versions and some contexts). Try:
DTML-object <dtml-call "REQUEST.set('name',['john', 'bill', 'george'])"> <dtml-in zsql> .... </dtml-in> Dieter
I have a short DTML Method intended to handle file uploads to a folder. In order for it to work, however, I need to enable "View" for Anonymous, which I don't want to do, or the file upload fails with "You are not authorized to access manage_addFile." (trace below) ... As I've delved into this problem however, I have come to notice that the class <AccesControl.Owned.Owned>, believes this item is owned by the anonymous user, which it is definitely not. Anyone have any idea on why this upload request is eventually made in the name of the Anonymous? Where is the method manage_addFile? Any ideas that might help? Thanks in advance John Ziniti An error was encountered while publishing this resource. Unauthorized You are not authorized to access manage_addFile. Traceback (innermost last): File /u01/zope/Zope-2.3.3-src/lib/python/ZPublisher/Publish.py, line 223, in publish_module File /u01/zope/Zope-2.3.3-src/lib/python/ZPublisher/Publish.py, line 187, in publish File /u01/zope/Zope-2.3.3-src/lib/python/ZPublisher/Publish.py, line 171, in publish File /u01/zope/Zope-2.3.3-src/lib/python/ZPublisher/mapply.py, line 160, in mapply (Object: post_new_document) File /u01/zope/Zope-2.3.3-src/lib/python/ZPublisher/Publish.py, line 112, in call_object (Object: post_new_document) File /u01/zope/Zope-2.3.3-src/lib/python/OFS/DTMLDocument.py, line 189, in __call__ (Object: post_new_document) File /u01/zope/Zope-2.3.3-src/lib/python/DocumentTemplate/DT_String.py, line 540, in __call__ (Object: post_new_document) File /u01/zope/Zope-2.3.3-src/lib/python/DocumentTemplate/DT_Let.py, line 149, in render (Object: fname="_.string.split(REQUEST.form['new_upload'].filename,'\\')[-1]") File /u01/zope/Zope-2.3.3-src/lib/python/DocumentTemplate/DT_With.py, line 151, in render (Object: Items) File /u01/zope/Zope-2.3.3-src/lib/python/DocumentTemplate/DT_Util.py, line 333, in eval (Object: manage_addFile(_['fname'], REQUEST.form['new_upload'], REQUEST=REQUEST)) (Info: manage_addFile) File /u01/zope/Zope-2.3.3-src/lib/python/OFS/DTMLMethod.py, line 261, in validate (Object: post_new_document) File /u01/zope/Zope-2.3.3-src/lib/python/AccessControl/SecurityManager.py, line 144, in validate File /u01/zope/Zope-2.3.3-src/lib/python/AccessControl/ZopeSecurityPolicy.py, line 206, in validate Unauthorized: (see above) "
Just for consistency, and in case anyone ever does a search ... This problem was due to the fact that /acl_users was replaced by an LDAPAdapter. LDAPAdapter does not implement the BasicUserFolder methods getUserById() and getUser() ... so these were being passed to the superclass, which had no idea about the users in the LDAP database. Therefore, None was returned as the owner, which somehwere along the line, was translated into 'Anonymous'... To fix the problem, a quick hack of a getUserById() method was written for LDAPAdapter ... and Zope was restarted ... bingo !!! On Mon, 30 Jul 2001 14:06:42 -0400 "John Ziniti" <john.ziniti@channing.harvard.edu> wrote:
I have a short DTML Method intended to handle file uploads to a folder. In order for it to work, however, I need to enable "View" for Anonymous, which I don't want to do, or the file upload fails with "You are not authorized to access manage_addFile." (trace below) ...
As I've delved into this problem however, I have come to notice that the class <AccesControl.Owned.Owned>, believes this item is owned by the anonymous user, which it is definitely not.
Anyone have any idea on why this upload request is eventually made in the name of the Anonymous?
Where is the method manage_addFile?
Any ideas that might help?
Thanks in advance
John Ziniti
An error was encountered while publishing this resource.
Unauthorized
You are not authorized to access manage_addFile. Traceback (innermost last): File /u01/zope/Zope-2.3.3-src/lib/python/ZPublisher/Publish.py, line 223, in publish_module File /u01/zope/Zope-2.3.3-src/lib/python/ZPublisher/Publish.py, line 187, in publish File /u01/zope/Zope-2.3.3-src/lib/python/ZPublisher/Publish.py, line 171, in publish File /u01/zope/Zope-2.3.3-src/lib/python/ZPublisher/mapply.py, line 160, in mapply (Object: post_new_document) File /u01/zope/Zope-2.3.3-src/lib/python/ZPublisher/Publish.py, line 112, in call_object (Object: post_new_document) File /u01/zope/Zope-2.3.3-src/lib/python/OFS/DTMLDocument.py, line 189, in __call__ (Object: post_new_document) File /u01/zope/Zope-2.3.3-src/lib/python/DocumentTemplate/DT_String.py, line 540, in __call__ (Object: post_new_document) File /u01/zope/Zope-2.3.3-src/lib/python/DocumentTemplate/DT_Let.py, line 149, in render (Object: fname="_.string.split(REQUEST.form['new_upload'].filename,'\\')[-1]") File /u01/zope/Zope-2.3.3-src/lib/python/DocumentTemplate/DT_With.py, line 151, in render (Object: Items) File /u01/zope/Zope-2.3.3-src/lib/python/DocumentTemplate/DT_Util.py, line 333, in eval (Object: manage_addFile(_['fname'], REQUEST.form['new_upload'], REQUEST=REQUEST)) (Info: manage_addFile) File /u01/zope/Zope-2.3.3-src/lib/python/OFS/DTMLMethod.py, line 261, in validate (Object: post_new_document) File /u01/zope/Zope-2.3.3-src/lib/python/AccessControl/SecurityManager.py, line 144, in validate File /u01/zope/Zope-2.3.3-src/lib/python/AccessControl/ZopeSecurityPolicy.py, line 206, in validate Unauthorized: (see above) "
_______________________________________________ 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 )
-- John Ziniti Channing Laboratory Brigham and Women's Hospital 181 Longwood Avenue Brookline, MA 02115 john.ziniti@channing.harvard.edu
On Sun, 15 Jul 2001, Fabrizio wrote:
Hello,
How can I perform a "OR" search on a SQL database field using a web form ?
E.g. :
I have a SQL database table with fields "name", "surname" and the following records:
Jimmy Carter Ronald Reagan George Bush Bill Clinton
I would like to search the "name" field through a web form and write :
George OR Jimmy
And it should return :
Jimmy Carter George Bush
Your question is a bit vague. What kind of web form do you have? A good general hint would be the SQL IN() syntax: WHERE firstname IN ('Jimmy','George') which could be in the ZSQL Method as a sequence over a list. -- Joel Burton <jburton@scw.org> Director of Information Systems, Support Center of Washington
participants (5)
-
Dieter Maurer -
Fabrizio -
Joel Burton -
John Ziniti -
John Ziniti