This must be a newbie question: I installed ZCatalogQuery to search a Catalog for a certain word in title OR PrincipiaSearchSource. The syntax is told to be: Catalog(title=’spam’, PrincipiaSearchSource=’spam’) I don't know how the word 'spam' in this case is replaced by the text, entered in a search form. Can anybody provide me a working example of such a query in DTML?
Stephan Goeldi wrote at 2003-5-24 10:42 +0200:
This must be a newbie question:
It's a question of someone that did not read the available documentation carefully...
I installed ZCatalogQuery to search a Catalog for a certain word in title OR PrincipiaSearchSource. The syntax is told to be:
Catalog(title=’spam’, PrincipiaSearchSource=’spam’)
I don't know how the word 'spam' in this case is replaced by the text, entered in a search form.
You have two options: * Use Python's "%" (format) operator (--> Python Library reference) It allows you to replace format indicators in format strings by dynamic content. * "ZCatalogQuery" provides a way to pass in parameters to the query (--> "ZCatalogQuery" documentation). Dieter
It's a question of someone that did not read the available documentation carefully...
I read it very carefully, but don't seem to be the ideal target group ;-) My problem is, that I see this example in the query: title == ’spam’ or PrincipiaSearchSource == ’spam’ I would now replace the word 'spam' with a word, entered in a search form. I tried: <dtml-in expr="Catalog.query(title == &dtml-word or PrincipiaSearchSource == &dtml-word)"> which doesn't work (same for some variants of the above). Do you believe me now, that I am a newbie?
Stephan Goeldi wrote at 2003-5-26 15:03 +0200:
It's a question of someone that did not read the available documentation carefully...
I read it very carefully, but don't seem to be the ideal target group ;-)
My problem is, that I see this example in the query:
title == ’spam’ or PrincipiaSearchSource == ’spam’
I would now replace the word 'spam' with a word, entered in a search form. I tried:
<dtml-in expr="Catalog.query(title == &dtml-word or PrincipiaSearchSource == &dtml-word)">
which doesn't work (same for some variants of the above).
Do you believe me now, that I am a newbie?
Apparently, you are also a person who does not like to read :-( I am sure, I not only wrote the (potentially insulting) phrase quoted above but also listed two options for you. 1. Use Python's format operator ("%") (see Python Library Reference) 2. Use ZCatalogQuery's parameter interpolation (see the ZCatalogQuery documentation). I looked it up for you: It is the "CatalogQuery-HowTo" document, section "Expressions in Queries". There is an example there, ready to use.... And as the above 'expr="...&dtml-XXX;"' indicates additional need for background reading, you should read the Zope Book or maybe <http://www.dieter.handshake.de/pyprojects/zope/book/chap3.html> You can be sure that without carefull background reading, your work with Zope will take at least an order of magnitude longer than necessary. Dieter
participants (2)
-
Dieter Maurer -
Stephan Goeldi