[Zope] DMTL-IF: Listing Documents that contain queryword

Dylan Reinhardt zope at dylanreinhardt.com
Sat Nov 22 19:12:11 EST 2003


On Sat, 2003-11-22 at 10:13, Sean Lee wrote:
> Since Documents already have the word I need in dtml-var Title (Category
> One: Whatever Title), I'd like to use a Web form to pass the query
> string and get rid of having to manually set Properties for each
> Document.
> I'd like to list any Document that contains string "query", like: 
> "select Documents where <dtml-var title> like queryword"

Here's a Python Script that assumes that the string you get passed in
can be found at the *beginning* of the title and the querystring
variable is called "category":

----
docs = context.objectValues(object_type)
target_len = len(category)
collector = []
for doc in docs:
    if doc.title[:target_len] == category:
        collector.append(doc)
return collector
----

HTH,

Dylan




More information about the Zope mailing list