[Zope] Keyword Index Question
VanL
vlindberg@verio.net
Tue, 30 Jul 2002 14:10:53 -0600
Hello,
I have an object which is included in a ZCatalog that watches, among
other things, the attributes 'keywords' (for a keyword index) and
'fulltext' (for a text index).
In the obect definition, I have the following code:
def __init__(self, default_catalog='mycatalog'):
self.default_catalog = str(default_catalog).strip()
self.keywords = self.get_indexable('keyword')
self.fulltext = self.get_indexable('fulltext')
def get_indexable(self, index_type):
" Dynamically build indexable attributes "
propdict = PropertyManager.propdict(self)
if index_type == 'keyword':
keylist = []
for propname in propdict.keys():
thisID, thisVal = propname, propdict[propname]
thisType = PropertyManager.getPropertyType(self, thisID)
if thisType == 'string':
keylist.append(propdict[thisID])
elif thisType == 'boolean':
keylist.append(thisID)
return keylist
elif index_type == 'fulltext':
alltext = ''
for propname in propdict.keys():
thisID, thisVal = propname, propdict[propname]
thisType = PropertyManager.getPropertyType(self, thisID)
if thisType == 'text': alltext = alltext + propdict[thisID]
return alltext
else: return None
I also reindex_object each time I change a property, as shown in the
example product ZCatalogedObject.
However, I don't get what I expect. First, even though my class
inhereits from CatalogAware, new objects aren't always added to the
zcatalog.
Second, when I look at the keywords actually indexed, I see this:
keywords [{'id': 'title', 'mode': 'w', 'type': 'string'}]
Any idea what I am doing wrong?
Thanks,
VL
What I want is a