[Zope] MySQL Methods and Names?

Stephen Pitts smpitts@midsouth.rr.com
Fri, 28 Jan 2000 15:48:05 +0000


On Sun, Feb 24, 2036 at 04:48:45PM +0000, Glenn Williams wrote:
> Hi All,
> 
> I have been setting up a MySQL database for book selling, and came across what
> seems to be a slight problem. I have a table with a column called 'title'.
> When I wrote the ZSQL method, using the following code:
> 
> SELECT title FROM titles
> WHERE 
>       <dtml-sqltest title
>                     column=title
>                     op=like
>                     type=string>
> 
> if the user hits RETURN without entering a value for title, Zope seems to look
> up the folder hierarchy and insert the title of the document. That seems
> reasonable, but how do I prevent that from happening?
That's one of the core principles of Zope: Acquisition! If you reference
a name in the namespace, Zope will recursively move up your site trying
to find that name. 

Put some code in whatever searches using the ZSQLMethod:
<dtml-if "not title">
Please enter a title and try the search again
<dtml-else>
Your search results...
</dtml-if>
-- 
Stephen Pitts
smpitts@midsouth.rr.com
webmaster - http://www.mschess.org