Re: [Zope-dev] Z SQL: "optional" isn't?
On Mon, 29 May 2000, Kyler B. Laird wrote: > This is not the same functionality as is provided > by the "optional" attribute. How would I use it > with an integer, for example? I don't want a > default value; I want the option of not having > the value set at all. > > I like the optional attribute. I'd like to see > it do more than sit idle in the code. You don't have to do the typechecking in the 'arguments' box if you don't want. eg. in your arguments section: course="" subject="" And your method: select * from enrolments The definition of the 'optional' tag from the docs might help here: '''A flag indicating if the test is optional. If the test is optional and no value is provided for a variable, or the value provided is an invalid empty string, then no text is inserted''' Hmm... looking at this definition, it seems you have found a bug (but setting the default value to "" in the arguments section will provide a workaround). Or maybe 'no value provided' means 'is None'. Anyone from DC want to provide a ruling? :-) -- Stuart Bishop Work: [EMAIL PROTECTED] Senior Systems Alchemist Play: [EMAIL PROTECTED] Computer Science, RMIT University ___ Zope-Dev maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope )
Re: [Zope-dev] Z SQL: "optional" isn't?
On Tue, 30 May 2000 17:09:20 +1000 (EST) you wrote: >> I like the optional attribute. I'd like to see >> it do more than sit idle in the code. > >You don't have to do the typechecking in the 'arguments' box if you don't >want. eg. in your arguments section: > >course="" >subject="" O.k., it appears that I can still use that with integers. I can live with that. I don't like setting an integer to what appears to be a string, but it does work. > >select * from enrolments > > > > > >The definition of the 'optional' tag from the docs might help here: >'''A flag indicating if the test is optional. If the test is optional >and no value is provided for a variable, or the value provided is >an invalid empty string, then no text is inserted''' I should have been more specific. I was referring to the "optional" attribute of the *argument* (not the sqltest). I found that it's coded in Aqueduct.py, but I'm not aware of any way to set it from the Z SQL method form. >Hmm... looking at this definition, it seems you have found a bug >(but setting the default value to "" in the arguments section will >provide a workaround). Or maybe 'no value provided' means 'is None'. >Anyone from DC want to provide a ruling? :-) Originally, after reading the above ("optional" in sqltest) definition, I'd hoped to be able to simply list the variable in the arguments section and make it optional in the sqltest. After looking at the code, I determined that this was not a reasonable expectation. (What if I used two sqltests and it was only optional in one?) In the course of investigating this, however, I found that an optional attribute for an argument is recognized. It seems like this is what should be used. I can live with it either way, but I think that optional is better than integer_var="". I'd like to see whatever is chosen documented, and I'd like to see "optional" removed from Aqueduct.py if it's not going to be supported. (Maybe it's used by something else?) --kyler ___ Zope-Dev maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope )
Re: [Zope-dev] Z SQL: "optional" isn't?
On Mon, 29 May 2000 21:56:33 +0200 (CEST) you wrote: > > Error, Bad Request: ['version'] >You want to use "default values" in your SQL method argument list. > >The details are described in "ZSQL/ZSQL.2.5.2.html". What's the URL for this? I'm looking through the pointers from the documentation page and only finding http://www.zope.org/Documentation/Guides/ZSQL-HTML/ZSQL.1.5.2.html I even tried a search and only came up with ZSQL 1.* hits. >Quote from "ZSQL2.5.2.html": > >> See Database method input argument format: Argument name and type are >> separated by a colon. A equal sign separates the default value from >> the name and type. The default value is a string representation of the >> desired value. If the default value contains spaces, or is an empty >> string, then it must be surrounded by double quotes.) This is not the same functionality as is provided by the "optional" attribute. How would I use it with an integer, for example? I don't want a default value; I want the option of not having the value set at all. I like the optional attribute. I'd like to see it do more than sit idle in the code. --kyler ___ Zope-Dev maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope )
Re: [Zope-dev] Z SQL: "optional" isn't?
Kyler B. Laird writes: > I'd like to build a Z SQL method for *many* > people to use to list courses that we offer. > I don't want to require that all queries > using it understand all of the columns, but > I do want to be able to modify the query in > many ways. > > This works only if I provide at least an empty > string for all values. If I don't provide a > value at all for one of the arguments, I get > Error, Bad Request: ['version'] You want to use "default values" in your SQL method argument list. The details are described in "ZSQL/ZSQL.2.5.2.html". You already got this advice. You failed, because you used the wrong kind of quotes (i.e. single rather than double quotes). Quote from "ZSQL2.5.2.html": > See Database method input argument format: Argument name and type are > separated by a colon. A equal sign separates the default value from > the name and type. The default value is a string representation of the > desired value. If the default value contains spaces, or is an empty > string, then it must be surrounded by double quotes.) > Pattern:name:type="default" Dieter ___ Zope-Dev maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope )
Re: [Zope-dev] Z SQL: "optional" isn't?
On Sat, 27 May 2000, Kyler B. Laird wrote: > I hope it's not documented anywhere; it doesn't > work either. > > It *does* allow the method to run without > setting the arguments, but it generates SQL > like "where subject=''". > > Someone had a good vision when writing the > documentation for the sqltest optional flag. > I just want it to work. Oops the default argument looks like it needs to be in double quotes. So what I said before, but subject:string="" -- Stuart Bishop Work: [EMAIL PROTECTED] Senior Systems Alchemist Play: [EMAIL PROTECTED] Computer Science, RMIT University ___ Zope-Dev maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope )
Re: [Zope-dev] Z SQL: "optional" isn't?
On Fri, 26 May 2000, Kyler B. Laird wrote: > > > > > > > > > > This works only if I provide at least an empty > string for all values. If I don't provide a > value at all for one of the arguments, I get In your 'Options' box for your ZSQL method, you can specify a default value for arguments if they were not passed: subject:string = '' course_nbr: string = '' Don't know if/where it is documented. -- Stuart Bishop Work: [EMAIL PROTECTED] Senior Systems Alchemist Play: [EMAIL PROTECTED] Computer Science, RMIT University ___ Zope-Dev maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope )
Re: [Zope-dev] Z SQL: "optional" isn't?
On Sat, 27 May 2000 13:07:50 +1000 (EST) you wrote: >In your 'Options' box for your ZSQL method, you can specify a default >value for arguments if they were not passed: > >subject:string = '' >course_nbr: string = '' > >Don't know if/where it is documented. I hope it's not documented anywhere; it doesn't work either. It *does* allow the method to run without setting the arguments, but it generates SQL like "where subject=''". Someone had a good vision when writing the documentation for the sqltest optional flag. I just want it to work. --kyler ___ Zope-Dev maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope )
Re: [Zope-dev] Z SQL: "optional" isn't?
On Fri, May 26, 2000 at 02:59:38PM -0500, Kyler B. Laird wrote: > > I'd like to build a Z SQL method for *many* > people to use to list courses that we offer. > I don't want to require that all queries > using it understand all of the columns, but > I do want to be able to modify the query in > many ways. > > So...after reading > http://yyy.zope.org/Documentation/Guides/ZSQL-HTML/ZSQL.1.5.3.html > optional > > A flag indicating if the test is optional. > If the test is optional and no value is > provided for a variable, or the value > provided is an invalid empty string, then > no text is inserted. > I thought I could just use "optional" > with all of my sqltests. > select * from course_catalog > > > > > > > > > > I have never used that corner of ZSQL methods. I have a guesses. I think that the method is working fine, but the nature of HTTP posting is giving you trouble. Remember, a REQUEST typically only contains non-null fields. There are three suggestions on fixing this. 1) preseed the calling form by putting in a BEFORE the form. This way, normal acquisition will get you an empty string even if there is no value entered in the form. 2) A bit more of a pain, but certainly doable. Remember that you can use ordinary logic in a ZSQL method. You can use choose among multiple cases in a single method. But, here you have 16 cases, which is unpleasant. Is it really true that ALL of these can be simultaneosly empty? 3) Considerable more pain, with some loss of safety. Construct the body of your method on the fly. Pass it in as an argument, and call that. For certain forms, this is necessary (if for example the user can modify the form generation process). ___ Zope-Dev maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope )
[Zope-dev] Z SQL: "optional" isn't?
I'd like to build a Z SQL method for *many* people to use to list courses that we offer. I don't want to require that all queries using it understand all of the columns, but I do want to be able to modify the query in many ways. So...after reading http://yyy.zope.org/Documentation/Guides/ZSQL-HTML/ZSQL.1.5.3.html optional A flag indicating if the test is optional. If the test is optional and no value is provided for a variable, or the value provided is an invalid empty string, then no text is inserted. I thought I could just use "optional" with all of my sqltests. select * from course_catalog This works only if I provide at least an empty string for all values. If I don't provide a value at all for one of the arguments, I get Error, Bad Request: ['version'] SQL used: Could not render the query template! Traceback (innermost last): File /data/www/Zope/Zope-2.2.0a1-src/lib/python/ZPublisher/Publish.py, line 224, in publish_module File /data/www/Zope/Zope-2.2.0a1-src/lib/python/ZPublisher/Publish.py, line 189, in publish File /data/www/Zope/Zope-2.2.0a1-src/lib/python/Zope/__init__.py, line 221, in zpublisher_exception_hook (Object: list_courses) File /data/www/Zope/Zope-2.2.0a1-src/lib/python/ZPublisher/Publish.py, line 175, in publish File /data/www/Zope/Zope-2.2.0a1-src/lib/python/ZPublisher/mapply.py, line 160, in mapply (Object: manage_test) File /data/www/Zope/Zope-2.2.0a1-src/lib/python/ZPublisher/Publish.py, line 112, in call_object (Object: manage_test) File /data/www/Zope/Zope-2.2.0a1-src/lib/python/Shared/DC/ZRDB/DA.py, line 347, in manage_test (Object: list_courses) File /data/www/Zope/Zope-2.2.0a1-src/lib/python/Shared/DC/ZRDB/DA.py, line 324, in manage_test (Object: list_courses) File /data/www/Zope/Zope-2.2.0a1-src/lib/python/Shared/DC/ZRDB/DA.py, line 426, in __call__ (Object: list_courses) File /data/www/Zope/Zope-2.2.0a1-src/lib/python/Shared/DC/ZRDB/Aqueduct.py, line 150, in _argdata (Object: list_courses) Bad Request: (see above) Looking at Aqueduct.py, I don't understand why it's not catching the "optional" arg. Using my limited Python knowledge, I commented out lines 149 and 150 of Aqueduct.py and now it works great. Once again, I'm glad that I can add these awful kludges instead of waiting for the vendor, but this is something that I hope is fixed soon. --kyler ___ Zope-Dev maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope )