[Zope] Searching a Zope site (in the traditional way)

Martijn Pieters mj@antraciet.nl
Mon, 15 Mar 1999 17:23:03 +0100


At 14:55 15/03/99 , Tony McDonald wrote:
>How do you do this?, ie to get a list of files/objects  that contain 
>the search term, laid out in a way that the external user would 
>recognise.
>
>I don't mean the 'find' tag in the manage screens, by the way...
>

The find management screen does give helpful hints. If you want to
implement this kind of searching, you'll have to use the same techniques.
These are however largely undocumented.

The file lib/python/OFS/findResult.dtml should give you a lot of hints on
how to implement a search command. It comes down to calling PrincipiaFind
on a Folder with the right arguments:

obj, obj_ids, obj_metatypes, obj_searchterm, obj_expr, obj_mtime,
obj_mspec, obj_permission, obj_roles, search_sub, REQUEST, result, pre

where

* obj -- base folder to start at

* obj_ids -- (optional) list of object ID's to search

* obj_metatypes -- (optional) list of meta types to search for (if the
string 'all' is in this list, all objects, whatever their meta type will be
included in the results).

* obj_searchterm -- (optional) literal text to search for in the *source*
of DTML Documents and DTML Methods.

* obj_expr -- (optional) DTML expression (as would be used in the expr
attribute of for example the var tag). If this expression returns true
within the context of an object, the object is included in the search
results. You could use this for testing on certain properties, like 'foo=bar'.

* obj_mtime -- (optional) DateTime object or string that can be converted
to a DateTime object, specifying a modification time to compare objects
against. Will on default return objects that have been modified since
obj_mtime.

* obj_mspec -- (optional) When used with obj_mspec, and set to '<',
PrincipiaFind will only return objects which have been last modified before
the date and time specified by obj_mtime.

* obj_permission -- (optional) To be used together with obj_roles. Check if
the roles specified by obj_roles have the obj_permission permission. Only
these objects are included in the results.

* obj_roles -- (optional) List of roles to check for obj_permission access.
See obj_permission.

* search_sub -- (optional) if true, search subobjects recursively.

* REQUEST -- (optional) REQUEST object, used to make sure that
AUTHENTICATED_USER is available for obj_expr expressions.

* result -- a list of objects to be included in the returned results. Used
by the PrincipiaFind method when recursively searching subobjects.
Generally of no use to us humble DTML programmers.

* pre -- prefix the IDs in the returned result list with pre and a slash.
So, when called with pre='foo', and bar is the only object found,
PrincipiaFind will return the list of tuples: [('foo/bar', foo)]. This
argument is used when recursively searching subobjects, where pre is the
relative URL of the object searched.  Generally of no use to us humble DTML
programmers.

The method returns a list of tuples, where the first element of every tuple
is the relative URL of the object found (relative to the starting point),
and the second element is the object itself. 


--
M.J. Pieters, Web Developer
| Antraciet http://www.antraciet.nl
| Tel: +31-35-6254545 Fax: +31-35-6254555
| mailto:mj@antraciet.nl http://www.antraciet.nl/~mj
| PGP: http://wwwkeys.nl.pgp.net:11371/pks/lookup?op=get&search=0xA8A32149
------------------------------------------