Commit 6106323a authored by Ayush Tiwari's avatar Ayush Tiwari Committed by Ayush Tiwari

sql_catalog: Drop usage of getattr from SQLCatalog

This would increase compatibility between accessors in erp5_catalog and
remove the need of copy and patch. At the same time, it also helps in
increasing performance as using _getOb is always less costly than
getattr, as it reduces the need to look in acquisition.

One of the difference between SQL and ERP5 Catalog is how they
handle their properties. For ERP5Catalog, we use property_sheets
which generate setters and getters, for SQLCatalog, properties
just act as attributes(as one can expect from a property set
on a class).

This creates a difference on how we use them, especially for
list_type properties, which have accessors like get<PropertyName>List
to get the list of objects. For SQLCatalog, there is no such thing.
This creates problem whereever 'get<PropertyName>' or getProperty(<name>)
was being used to get multiple property types.
parent 9ae23083
...@@ -3,8 +3,8 @@ portal = context.getPortalObject() ...@@ -3,8 +3,8 @@ portal = context.getPortalObject()
# This scriptable key supports content_translation if the table is present # This scriptable key supports content_translation if the table is present
catalog = portal.portal_catalog.getSQLCatalog() catalog = portal.portal_catalog.getSQLCatalog()
if 'content_translation' in catalog.getProperty('sql_search_tables'): if 'content_translation' in getattr(catalog, 'sql_search_tables', ()):
if [x for x in catalog.getProperty('sql_catalog_search_keys', []) if 'Mroonga' in x]: if any('Mroonga' in x for x in catalog.getSqlCatalogSearchKeysList()):
return AndQuery(SimpleQuery(**{'content_translation.translated_text': value, 'comparison_operator': 'mroonga_boolean'}), return AndQuery(SimpleQuery(**{'content_translation.translated_text': value, 'comparison_operator': 'mroonga_boolean'}),
Query(**{'content_translation.property_name': 'title'})) Query(**{'content_translation.property_name': 'title'}))
else: else:
......
...@@ -59,7 +59,7 @@ class CatalogKeywordKeyConfiguratorItem(ConfiguratorItemMixin, XMLObject): ...@@ -59,7 +59,7 @@ class CatalogKeywordKeyConfiguratorItem(ConfiguratorItemMixin, XMLObject):
error_list = [] error_list = []
portal = self.getPortalObject() portal = self.getPortalObject()
catalog = portal.portal_catalog.getSQLCatalog() catalog = portal.portal_catalog.getSQLCatalog()
key_list = list(catalog.getProperty('sql_catalog_keyword_search_keys', ())) key_list = list(catalog.getSqlCatalogSearchKeysList())
for k in self.key_list: for k in self.key_list:
if k not in key_list: if k not in key_list:
error_list.append(self._createConstraintMessage( error_list.append(self._createConstraintMessage(
......
This diff is collapsed.
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