[Zope] Re: Advanced search in ZCatalog (Micha)

michael Kobald micha@kobald.de
Mon, 13 Nov 2000 21:55:20 +0100


Hi,
I played with ZCatalog and ZClasses a time ago.
Due to the fact that ZCatalog can Index all Objects - You Can Index a
Method, .....!!!
This Methods can be External-, Phython-, or DTML-Methods.
But they have to return something to the catalog (DTML-RETURN Tag).
You can give this method a name like "PrincipiaSearchSource" or what the
hell you think of.

In my case I index about 10 different ZClass, 100 Instances of them, with a
PythonMethod called text_inhalt (text_contents)
Param: self
Code
return string.join((self.id, self.inhalt), '; ')

Or in an  subclass
return string.join((self.id, self.teaser, self.gericht, self.keys, self.art,
self.norm, self.parteien), '; ')

Be warned you can use a DTML Method and return something with the
dtml-return tag, but this is not working very well within a ZCLass, !!!
??????

P.S.:
If you want to call a resultObject (e.g. a ZClass) directly through
Zope/DTML/Python use the PyMethod "fetchObj" much cooler than only via
catalog.getpath (which is link /hfg/kkjk/)

to do somthing like this:

<dtml-in mein> ****Result from a canned search

<dtml-call
"REQUEST.set('meineURL',fetchObj(_,Catalog.getpath(_.int(_['sequence-item'])
)))">****convert /parent/child to an real object parent.child

<dtml-var meineURL>  *** points to a ZClass [Base:Renderable] calling the
Object/Class directly, which renders itself

</dtml-in>

use something like this:

Python Method: fetchObj

Param: _,fetchStr, attr=None

obj = _
for p in string.split(fetchStr, '/'):
   obj = obj[p]
if attr is None:
   return obj
else:
   return render(_.getattr(obj, attr))



Greetings from Heidelberg

Michael Kobald