[Erp5-report] r37163 ivan - in /erp5/trunk/products/ERP5Type: ./ PropertySheet/
nobody at svn.erp5.org
nobody at svn.erp5.org
Fri Jul 16 10:27:42 CEST 2010
Author: ivan
Date: Fri Jul 16 10:27:41 2010
New Revision: 37163
URL: http://svn.erp5.org?rev=37163&view=rev
Log:
Use portal type based definitions for searchable text generators.
Modified:
erp5/trunk/products/ERP5Type/Base.py
erp5/trunk/products/ERP5Type/PropertySheet/BaseType.py
Modified: erp5/trunk/products/ERP5Type/Base.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/Base.py?rev=37163&r1=37162&r2=37163&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/Base.py [utf8] (original)
+++ erp5/trunk/products/ERP5Type/Base.py [utf8] Fri Jul 16 10:27:41 2010
@@ -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
Modified: erp5/trunk/products/ERP5Type/PropertySheet/BaseType.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/PropertySheet/BaseType.py?rev=37163&r1=37162&r2=37163&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/PropertySheet/BaseType.py [utf8] (original)
+++ erp5/trunk/products/ERP5Type/PropertySheet/BaseType.py [utf8] Fri Jul 16 10:27:41 2010
@@ -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': []
+ },
)
More information about the Erp5-report
mailing list