Commit 84a48ea8 authored by Alexandre Boeglin's avatar Alexandre Boeglin

Added support for sql_catalog_related_keys to Business Templates.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@2732 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 07e68def
...@@ -811,6 +811,42 @@ class CatalogResultKeyTemplateItem(BaseTemplateItem): ...@@ -811,6 +811,42 @@ class CatalogResultKeyTemplateItem(BaseTemplateItem):
BaseTemplateItem.uninstall(self, context, **kw) BaseTemplateItem.uninstall(self, context, **kw)
class CatalogRelatedKeyTemplateItem(BaseTemplateItem):
def install(self, context, **kw):
BaseTemplateItem.install(self, context, **kw)
try:
catalog = context.portal_catalog.getSQLCatalog()
except:
catalog = None
if catalog is None:
LOG('BusinessTemplate', 0, 'no SQL catalog was available')
return
for key in self._archive.keys():
if key not in catalog.sql_catalog_related_keys:
catalog.sql_catalog_related_keys = (key,) + catalog.sql_catalog_related_keys
def uninstall(self, context, **kw):
try:
catalog = context.portal_catalog.getSQLCatalog()
except:
catalog = None
if catalog is None:
LOG('BusinessTemplate', 0, 'no SQL catalog was available')
return
sql_search_result_keys = list(catalog.sql_catalog_related_keys)
for key in self._archive.keys():
if key in sql_catalog_related_keys:
sql_catalog_related_keys.remove(key)
catalog.sql_catalog_related_keys = sql_catalog_related_keys
BaseTemplateItem.uninstall(self, context, **kw)
class CatalogResultTableTemplateItem(BaseTemplateItem): class CatalogResultTableTemplateItem(BaseTemplateItem):
def install(self, context, **kw): def install(self, context, **kw):
...@@ -1043,6 +1079,7 @@ Business Template is a set of definitions, such as skins, portal types and categ ...@@ -1043,6 +1079,7 @@ Business Template is a set of definitions, such as skins, portal types and categ
_product_item = None _product_item = None
_role_item = None _role_item = None
_catalog_result_key_item = None _catalog_result_key_item = None
_catalog_related_key_item = None
_catalog_result_table_item = None _catalog_result_table_item = None
_message_translation_item = None _message_translation_item = None
...@@ -1124,6 +1161,10 @@ Business Template is a set of definitions, such as skins, portal types and categ ...@@ -1124,6 +1161,10 @@ Business Template is a set of definitions, such as skins, portal types and categ
self._catalog_result_key_item = CatalogResultKeyTemplateItem(self.getTemplateCatalogResultKeyList()) self._catalog_result_key_item = CatalogResultKeyTemplateItem(self.getTemplateCatalogResultKeyList())
self._catalog_result_key_item.build(self) self._catalog_result_key_item.build(self)
# Copy catalog related keys
self._catalog_related_key_item = CatalogRelatedKeyTemplateItem(self.getTemplateCatalogRelatedKeyList())
self._catalog_related_key_item.build(self)
# Copy catalog result tables # Copy catalog result tables
self._catalog_result_table_item = CatalogResultTableTemplateItem(self.getTemplateCatalogResultTableList()) self._catalog_result_table_item = CatalogResultTableTemplateItem(self.getTemplateCatalogResultTableList())
self._catalog_result_table_item.build(self) self._catalog_result_table_item.build(self)
...@@ -1198,6 +1239,7 @@ Business Template is a set of definitions, such as skins, portal types and categ ...@@ -1198,6 +1239,7 @@ Business Template is a set of definitions, such as skins, portal types and categ
# Actions, catalog # Actions, catalog
if self._action_item is not None: self._action_item.install(local_configuration) if self._action_item is not None: self._action_item.install(local_configuration)
if self._catalog_result_key_item is not None: self._catalog_result_key_item.install(local_configuration) if self._catalog_result_key_item is not None: self._catalog_result_key_item.install(local_configuration)
if self._catalog_related_key_item is not None: self._catalog_related_key_item.install(local_configuration)
if self._catalog_result_table_item is not None: self._catalog_result_table_item.install(local_configuration) if self._catalog_result_table_item is not None: self._catalog_result_table_item.install(local_configuration)
# It is better to clear cache because the installation of a template # It is better to clear cache because the installation of a template
...@@ -1220,6 +1262,7 @@ Business Template is a set of definitions, such as skins, portal types and categ ...@@ -1220,6 +1262,7 @@ Business Template is a set of definitions, such as skins, portal types and categ
# Actions, catalog # Actions, catalog
if self._action_item is not None: self._action_item.trash(local_configuration, new_bt._action_item) if self._action_item is not None: self._action_item.trash(local_configuration, new_bt._action_item)
if self._catalog_result_key_item is not None: self._catalog_result_key_item.trash(local_configuration, new_bt._catalog_result_key_item) if self._catalog_result_key_item is not None: self._catalog_result_key_item.trash(local_configuration, new_bt._catalog_result_key_item)
if self._catalog_related_key_item is not None: self._catalog_related_key_item.trash(local_configuration, new_bt._catalog_related_key_item)
if self._catalog_result_table_item is not None: self._catalog_result_table_item.trash(local_configuration, new_bt._catalog_result_table_item) if self._catalog_result_table_item is not None: self._catalog_result_table_item.trash(local_configuration, new_bt._catalog_result_table_item)
# Skins # Skins
...@@ -1261,6 +1304,7 @@ Business Template is a set of definitions, such as skins, portal types and categ ...@@ -1261,6 +1304,7 @@ Business Template is a set of definitions, such as skins, portal types and categ
# Actions, catalog # Actions, catalog
if self._action_item is not None: self._action_item.uninstall(local_configuration) if self._action_item is not None: self._action_item.uninstall(local_configuration)
if self._catalog_result_key_item is not None: self._catalog_result_key_item.uninstall(local_configuration) if self._catalog_result_key_item is not None: self._catalog_result_key_item.uninstall(local_configuration)
if self._catalog_related_key_item is not None: self._catalog_related_key_item.uninstall(local_configuration)
if self._catalog_result_table_item is not None: self._catalog_result_table_item.uninstall(local_configuration) if self._catalog_result_table_item is not None: self._catalog_result_table_item.uninstall(local_configuration)
# Skins # Skins
...@@ -1322,6 +1366,7 @@ Business Template is a set of definitions, such as skins, portal types and categ ...@@ -1322,6 +1366,7 @@ Business Template is a set of definitions, such as skins, portal types and categ
self._product_item = None self._product_item = None
self._role_item = None self._role_item = None
self._catalog_result_key_item = None self._catalog_result_key_item = None
self._catalog_related_key_item = None
self._catalog_result_table_item = None self._catalog_result_table_item = None
self._message_translation_item = None self._message_translation_item = None
......
...@@ -82,6 +82,11 @@ class BusinessTemplate: ...@@ -82,6 +82,11 @@ class BusinessTemplate:
'type' : 'lines', 'type' : 'lines',
'mode' : 'w', 'mode' : 'w',
'default' : () }, 'default' : () },
{ 'id' : 'template_catalog_related_key',
'description' : 'A list of ids of catalog related keys used by this module',
'type' : 'lines',
'mode' : 'w',
'default' : () },
{ 'id' : 'template_catalog_result_table', { 'id' : 'template_catalog_result_table',
'description' : 'A list of ids of catalog result tables used by this module', 'description' : 'A list of ids of catalog result tables used by this module',
'type' : 'lines', 'type' : 'lines',
......
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