[Zope3-Users] Catalog for newbies

Frank Burkhardt fbo2 at gmx.net
Thu Dec 8 10:56:20 EST 2005


On Tue, Dec 06, 2005 at 10:41:02AM -0700, Jeff Shell wrote:


> > 1. How do I search the catalog?


> catalog = zapi.getUtility(ICatalog, 'catalog', self.context)
> results = self._results = catalog.searchResults(textindexname='text to
> search for', fieldindexname=('low value', 'high value'))

Thank you.

I successfully managed to search my zope-site. Now I want a more
"future-proof" solution. I'd like to have a google-like search engine on my
site which means:
   * Somes words needs to be typed
   * A List of results is shown, containing all content objects where all
     words of the search query occur.
   * The search is not restricted to some special fields - I just want
     *everything* to be searched.

My idea:
   1. Define an interface

class ISearchable(object):
   sub getContent(self):
   	"""Returns the objects text"""

   sub getTitle(self):
      """Returns a name/title of the object"""

   sub getDigest(self):
      """Returns some few words from the beginning of the content"""

   2. Use a catalog and a text-index to index all ISearchable-implementing objects (field getContent,callable)
   3. Write Adapters for all content-classes used on my zope-server, adapting to ISearchable

Is this a "good" idea?

One more question:

How do I use adapters in python? I've got an object implementing interface
'IFoo'. How to I turn it into an object implementing 'IBar'?



More information about the Zope3-users mailing list