Re: [Zope] Newbie question: ZCatalog 'summary' meta-data
Curtis Matthews <cmatthews@cpcus.com> wrote:
Please find it in your heart to enlighten a newbie. :)
I've been able to find a lot of helpful documentation about how to use ZCatalogs and search interfaces, but one thing that has eluded me is the 'summary' meta-data feature. All I've been able to find out about this is it's supposed to store the first few hundred characters of a text document so that they can be displayed on a results report.
I now have a catalog of about 100+ DTML Documents, and every time I search it, the "summary" column of the results report is empty. I'm confused. I assumed ZCatalog builds this summary automatically...does it? If not, what extra stuff do I have to do to make it so?
Any troubleshooting suggestions would be appreciated.
The catalog has index for 'summary', because CatalogAware objects expose a 'summary' attribute (a method, actually) which performs as you describe. Unfortunately, DTMLDocument is *not* dervied from CatalogAware, and so has no such method. This gap accounts for other infelicitous (non)interaction between DTMLDocuments and ZCatalogs: DTMLDocuments are not automagically added/removed from the catalog when they are created/deleted, for instance. A workaround is to add a PythonMethod or ExternalMethod named 'summary' as a peer of your Catalog, defined so (assuming an EM): def summary( self, num=200 ): """Return a summary of the string form of the object.""" text=str( self ) n=min(num, len(text)) return text[:n] Note that the "string form" of a DTML document is the unrendered source, which may not be very useful to look at -- most will start off with '<dtml-var standard_html_header>...' and go downhill from there. You can, of course, tweak the summary code to return any property, or even a concatenated set of properties (like PrincipiaSearchSource does). Tres. -- ========================================================= Tres Seaver tseaver@digicool.com tseaver@palladion.com
participants (1)
-
Tres Seaver