Commit dd51053f authored by Ayush Tiwari's avatar Ayush Tiwari

erp5_catalog: Use getattr to get catalog attributes

Both SQL Catalog and the new ERP5 Catalog have all properties as their
attributes also, so its better to user `getattr` as it'll maintain
consistency betwen both.

This was required as in ERP5 Catalog, these properties are multivalued
propeties, so they have multiple accessors, so if we use 'getProperty',
we won't get the objects we desired. So, instead of relying on that, why
not just use the attributes.
parent 757ed1c9
......@@ -3,8 +3,8 @@ portal = context.getPortalObject()
# This scriptable key supports content_translation if the table is present
catalog = portal.portal_catalog.getSQLCatalog()
if 'content_translation' in catalog.getProperty('sql_search_tables'):
if [x for x in catalog.getProperty('sql_catalog_search_keys', []) if 'Mroonga' in x]:
if 'content_translation' in getattr(catalog, 'sql_search_tables', []):
if [x for x in getattr(catalog, 'sql_catalog_search_keys', []) if 'Mroonga' in x]:
return AndQuery(SimpleQuery(**{'content_translation.translated_text': value, 'comparison_operator': 'mroonga_boolean'}),
Query(**{'content_translation.property_name': 'title'}))
else:
......
......@@ -59,7 +59,7 @@ class CatalogKeywordKeyConfiguratorItem(ConfiguratorItemMixin, XMLObject):
error_list = []
portal = self.getPortalObject()
catalog = portal.portal_catalog.getSQLCatalog()
key_list = list(catalog.getProperty('sql_catalog_keyword_search_keys', ()))
key_list = list(getattr(catalog, 'sql_catalog_keyword_search_keys', ()))
for k in self.key_list:
if k not in key_list:
error_list.append(self._createConstraintMessage(
......
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