Commit 9dddec9c authored by Ivan Tyagov's avatar Ivan Tyagov

Use portal type based definitions for searchable text generators.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@37163 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 87fdb030
......@@ -3196,12 +3196,28 @@ class Base( CopyContainer,
### Content accessor methods
security.declareProtected(Permissions.View, 'getSearchableText')
def getSearchableText(self, md=None):
"""\
Used by the catalog for basic full text indexing
We should try to do some kind of file conversion here
"""
searchable_text = "%s %s %s" % (self.getTitle(), self.getDescription(),
self.getId())
Used by the catalog for basic full text indexing.
"""
searchable_text_list = []
portal_type = self.portal_types.getTypeInfo(self)
searchable_text_method_id_list = []
# generated from properties methods and add explicitly defined method_ids as well
for searchable_text_property_id in portal_type.getSearchableTextPropertyIdList():
method_id = convertToUpperCase(searchable_text_property_id)
searchable_text_method_id_list.extend(['get%s' %method_id])
searchable_text_method_id_list.extend(portal_type.getSearchableTextMethodIdList())
for method_id in searchable_text_method_id_list:
# XXX: how to exclude exclude acquisition (not working)
#if getattr(aq_base(self), method_id, None) is not None:
# method = getattr(self, method_id, None)
# should we do it as ZSQLCatalog should care for calling this method on proper context?
method = getattr(self, method_id, None)
if method is not None:
method_value = method()
if method_value is not None:
searchable_text_list.append(method_value)
searchable_text = ' '.join(searchable_text_list)
return searchable_text
# Compatibility with CMF Catalog / CPS sites
......
......@@ -100,5 +100,19 @@ class BaseType:
, 'label': 'Groups'
, 'select_variable':'getAvailableGroupList'
},
# searchable text method id list used by ZSQLCatalog
{ 'id': 'searchable_text_property_id'
, 'type': 'lines'
, 'mode': 'w'
, 'label': 'Searchable text property ids'
# default known to exists everythere properties
, 'default': ['title', 'description', 'id', 'reference', 'short_title']
},
{ 'id': 'searchable_text_method_id'
, 'type': 'lines'
, 'mode': 'w'
, 'label': 'Searchable text method Ids'
, 'default': []
},
)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment