ZCatalog: path & summary indices not generated
Zope Version: 2.4.1 on linux. When I tried to add a ZCatalog followed by finding objects to index using the default indices provided (path, summary, id, title etc), the 'path' and 'summary' indices are never generated. The 'summary' index is always an empty string and the 'path' index is 'None'. To get around the 'summary' not being indexed for DTMLMethod and DTMLDocument objects I had to add the following method to DTMLMethod.py: def summary(self): "Support for searching - the document's contents are searched." raw = self.read() stripped_raw = re.sub("<.*>", "", raw) n=min(200, len(stripped_raw)) return stripped_raw[:n] which basically strips out anything between '<' and '>' tags which should strip most of the DTML and HTML tags out to give a half decent 200 character summary. Unfortunately I tried the same with the 'path' index by adding the following to DTMLMethod.py def getPath(self): "Get path" return getPath(self) def path(self): "Get path" return join(self.getPhysicalPath(), "/") but the 'path' index only works it is a FieldIndex. When it's a PathIndex I get the value of None for all cataloged items. Surely someone else has come across these problems before using this basic catalog stuff?? Shane Rowatt Astracon Inc.
----- Original Message ----- From: "Shane Rowatt" <s.rowatt@astracon.com.au> To: <zope-dev@zope.org> Sent: Wednesday, October 03, 2001 00:54 Subject: [Zope-dev] ZCatalog: path & summary indices not generated
Unfortunately I tried the same with the 'path' index by adding the
following
to DTMLMethod.py
def getPath(self): "Get path" return getPath(self)
def path(self): "Get path" return join(self.getPhysicalPath(), "/")
but the 'path' index only works it is a FieldIndex. When it's a PathIndex I get the value of None for all cataloged items.
Shane, you don't have to provide special path() to your objects. The PathIndex works a bit different from the other indexes because it does not look for an attribute or method with a name equal to the name of your PathIndex. So how do PathIndexes work ? - ZCatalog calls PathIndex.index_object() for all objects to be cataloged. - index_object() determines the physical path the object and indexes this result inside the PathIndex data structure. We have not seen necessity to provide support for a user-defined hook. If you have some use cases let me know. Hope this helps ;-) Andreas
On Wednesday 03 October 2001 12:54 am, Shane Rowatt allegedly wrote:
Zope Version: 2.4.1 on linux.
When I tried to add a ZCatalog followed by finding objects to index using the default indices provided (path, summary, id, title etc), the 'path' and 'summary' indices are never generated. The 'summary' index is always an empty string and the 'path' index is 'None'.
Summary is not defined (as you found) for most plain objects. CatalogAware defines it, but unfortunately without stripping tags. You might check out my DTMLDocumentExt code which renders the document and strips the html tags. It is an extension of some code Dieter posted online a while back. You can find it at: http://www.zope.org/Members/Kaivo/DTMLDocumentExt [snip]
Surely someone else has come across these problems before using this basic catalog stuff??
Yup 8^)
Shane Rowatt Astracon Inc.
hth /---------------------------------------------------\ Casey Duncan, Sr. Web Developer National Legal Aid and Defender Association c.duncan@nlada.org \---------------------------------------------------/
participants (3)
-
Andreas Jung -
Casey Duncan -
Shane Rowatt