RE: [Zope] Zcatalog and PrincipiaSearchSource with Zclasses ?
At 17:43 21/10/99 , Michel Pelletier wrote:
Sure, why not just impliment a DTML Method in your ZClass called PrincipiaSearchSource that returns what you want indexed?
<dtml-return "title + author + body">
This won't work, because you can't index on the result of a DTML Method. The DTML Method doesn't get called with the usual client and REQUEST objects, so the method has no means of obtaining the title, author and body parameters. You can do it with an External Method: def AllField(self) return self.title + self.author + self.body or you could make a property on you object that on every update gets filled with the contents of title + author + body. -- Martijn Pieters, Web Developer | Antraciet http://www.antraciet.nl | Tel: +31-35-7502100 Fax: +31-35-7502111 | mailto:mj@antraciet.nl http://www.antraciet.nl/~mj | PGP: http://wwwkeys.nl.pgp.net:11371/pks/lookup?op=get&search=0xA8A32149 ------------------------------------------
This won't work, because you can't index on the result of a DTML
Method.
The DTML Method doesn't get called with the usual client and REQUEST objects, so the method has no means of obtaining the title, author and body parameters.
You can do it with an External Method:
def AllField(self) return self.title + self.author + self.body
or you could make a property on you object that on every update gets filled with the contents of title + author + body.
Thanks ! This really cleared up some things :-) my first venture into the great domain of external methods has now been triggered . exciting ! ------------------------------------------------ Geir B Hansen geirh@funcom.com Web-designer / Graphic artist Funcom Oslo ------------------------------------------------
Sure, why not just impliment a DTML Method in your ZClass called PrincipiaSearchSource that returns what you want indexed?
<dtml-return "title + author + body">
This won't work, because you can't index on the result of a DTML Method.
PythonMethod is perfect for this kind of thing. I just created PrincipiaSearchSource with code: return self.id+"; "+self.title+"; "+self.text ... and then re-indexed everything (so the catalog picked up on the method) and performed a search. Worked a treat! Regards, Garth. -- <gtk@well.com>
Sure, why not just impliment a DTML Method in your ZClass called PrincipiaSearchSource that returns what you want indexed?
<dtml-return "title + author + body">
This won't work, because you can't index on the result of a DTML Method.
PythonMethod is perfect for this kind of thing. I just created PrincipiaSearchSource with self as an argument and the following code: return self.id+"; "+self.title+"; "+self.text ... and then re-indexed everything (so the catalog picked up on the method) and performed a search. Worked a treat! return string.join((self.id, self.title, self.text,), '; ') would perhaps be more efficient, but isn't quite as readable. :) Regards, Garth. -- <gtk@well.com>
participants (3)
-
Geir B Hansen -
gtk -
Martijn Pieters