Commit 7ed1c352 authored by Nicolas Delaby's avatar Nicolas Delaby

Avoid raising NotFound Error on temporary Bt (BT for diff)

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@20781 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent e659d2d1
...@@ -349,7 +349,9 @@ class BusinessTemplateMissingDependency(Exception): pass ...@@ -349,7 +349,9 @@ class BusinessTemplateMissingDependency(Exception): pass
class BaseTemplateItem(Implicit, Persistent): class BaseTemplateItem(Implicit, Persistent):
""" """
This class is the base class for all template items. This class is the base class for all template items.
is_bt_for_diff means This BT is used to compare self temporary BT with installed BT
""" """
is_bt_for_diff = None
def __init__(self, id_list, **kw): def __init__(self, id_list, **kw):
self.__dict__.update(kw) self.__dict__.update(kw)
...@@ -1509,6 +1511,7 @@ class PortalTypeWorkflowChainTemplateItem(BaseTemplateItem): ...@@ -1509,6 +1511,7 @@ class PortalTypeWorkflowChainTemplateItem(BaseTemplateItem):
workflow_name = workflow workflow_name = workflow
if workflow[0] != '-' and \ if workflow[0] != '-' and \
workflow_name not in chain_dict['chain_%s' % portal_type]: workflow_name not in chain_dict['chain_%s' % portal_type]:
if not self.is_bt_for_diff:
raise NotFound, 'workflow %s not found in chain for portal_type %s'\ raise NotFound, 'workflow %s not found in chain for portal_type %s'\
% (workflow, portal_type) % (workflow, portal_type)
if self._objects.has_key(portal_type): if self._objects.has_key(portal_type):
...@@ -1516,7 +1519,7 @@ class PortalTypeWorkflowChainTemplateItem(BaseTemplateItem): ...@@ -1516,7 +1519,7 @@ class PortalTypeWorkflowChainTemplateItem(BaseTemplateItem):
self._objects[portal_type].append(workflow) self._objects[portal_type].append(workflow)
else: else:
self._objects[portal_type] = [workflow,] self._objects[portal_type] = [workflow,]
else: elif not self.is_bt_for_diff:
raise NotFound, 'portal type %s not found in workflow chain'\ raise NotFound, 'portal type %s not found in workflow chain'\
% portal_type % portal_type
...@@ -2214,6 +2217,7 @@ class ActionTemplateItem(ObjectTemplateItem): ...@@ -2214,6 +2217,7 @@ class ActionTemplateItem(ObjectTemplateItem):
self._objects[key].wl_clearLocks() self._objects[key].wl_clearLocks()
break break
else: else:
if not self.is_bt_for_diff:
raise NotFound, 'Action %r not found' %(id,) raise NotFound, 'Action %r not found' %(id,)
def install(self, context, trashbin, **kw): def install(self, context, trashbin, **kw):
...@@ -2471,7 +2475,7 @@ class SitePropertyTemplateItem(BaseTemplateItem): ...@@ -2471,7 +2475,7 @@ class SitePropertyTemplateItem(BaseTemplateItem):
break break
else: else:
obj = None obj = None
if obj is None: if obj is None and not self.is_bt_for_diff:
raise NotFound, 'the property %s is not found' % id raise NotFound, 'the property %s is not found' % id
self._objects[id] = (prop_type, obj) self._objects[id] = (prop_type, obj)
...@@ -2966,7 +2970,7 @@ class CatalogResultKeyTemplateItem(BaseTemplateItem): ...@@ -2966,7 +2970,7 @@ class CatalogResultKeyTemplateItem(BaseTemplateItem):
for key in self._archive.keys(): for key in self._archive.keys():
if key in sql_search_result_keys: if key in sql_search_result_keys:
key_list.append(key) key_list.append(key)
else: elif not self.is_bt_for_diff:
raise NotFound, 'Result key "%r" not found in catalog' %(key,) raise NotFound, 'Result key "%r" not found in catalog' %(key,)
if len(key_list) > 0: if len(key_list) > 0:
self._objects[self.__class__.__name__+'/'+'result_key_list'] = key_list self._objects[self.__class__.__name__+'/'+'result_key_list'] = key_list
...@@ -3057,7 +3061,7 @@ class CatalogRelatedKeyTemplateItem(BaseTemplateItem): ...@@ -3057,7 +3061,7 @@ class CatalogRelatedKeyTemplateItem(BaseTemplateItem):
for key in self._archive.keys(): for key in self._archive.keys():
if key in sql_search_related_keys: if key in sql_search_related_keys:
key_list.append(key) key_list.append(key)
else: elif not self.is_bt_for_diff:
raise NotFound, 'Related key "%r" not found in catalog' %(key,) raise NotFound, 'Related key "%r" not found in catalog' %(key,)
if len(key_list) > 0: if len(key_list) > 0:
self._objects[self.__class__.__name__+'/'+'related_key_list'] = key_list self._objects[self.__class__.__name__+'/'+'related_key_list'] = key_list
...@@ -3151,7 +3155,7 @@ class CatalogResultTableTemplateItem(BaseTemplateItem): ...@@ -3151,7 +3155,7 @@ class CatalogResultTableTemplateItem(BaseTemplateItem):
for key in self._archive.keys(): for key in self._archive.keys():
if key in sql_search_result_tables: if key in sql_search_result_tables:
key_list.append(key) key_list.append(key)
else: elif not self.is_bt_for_diff:
raise NotFound, 'Result table "%r" not found in catalog' %(key,) raise NotFound, 'Result table "%r" not found in catalog' %(key,)
if len(key_list) > 0: if len(key_list) > 0:
self._objects[self.__class__.__name__+'/'+'result_table_list'] = key_list self._objects[self.__class__.__name__+'/'+'result_table_list'] = key_list
...@@ -3243,7 +3247,7 @@ class CatalogKeywordKeyTemplateItem(BaseTemplateItem): ...@@ -3243,7 +3247,7 @@ class CatalogKeywordKeyTemplateItem(BaseTemplateItem):
for key in self._archive.keys(): for key in self._archive.keys():
if key in sql_keyword_keys: if key in sql_keyword_keys:
key_list.append(key) key_list.append(key)
else: elif not self.is_bt_for_diff:
raise NotFound, 'Keyword key "%r" not found in catalog' %(key,) raise NotFound, 'Keyword key "%r" not found in catalog' %(key,)
if len(key_list) > 0: if len(key_list) > 0:
self._objects[self.__class__.__name__+'/'+'keyword_key_list'] = key_list self._objects[self.__class__.__name__+'/'+'keyword_key_list'] = key_list
...@@ -3335,7 +3339,7 @@ class CatalogDateTimeKeyTemplateItem(BaseTemplateItem): ...@@ -3335,7 +3339,7 @@ class CatalogDateTimeKeyTemplateItem(BaseTemplateItem):
for key in self._archive.keys(): for key in self._archive.keys():
if key in sql_datetime_keys: if key in sql_datetime_keys:
key_list.append(key) key_list.append(key)
else: elif not self.is_bt_for_diff:
raise NotFound, 'DateTime key "%r" not found in catalog' %(key,) raise NotFound, 'DateTime key "%r" not found in catalog' %(key,)
if len(key_list) > 0: if len(key_list) > 0:
self._objects[self.__class__.__name__+'/'+'datetime_key_list'] = key_list self._objects[self.__class__.__name__+'/'+'datetime_key_list'] = key_list
...@@ -3427,7 +3431,7 @@ class CatalogFullTextKeyTemplateItem(BaseTemplateItem): ...@@ -3427,7 +3431,7 @@ class CatalogFullTextKeyTemplateItem(BaseTemplateItem):
for key in self._archive.keys(): for key in self._archive.keys():
if key in sql_full_text_keys: if key in sql_full_text_keys:
key_list.append(key) key_list.append(key)
else: elif not self.is_bt_for_diff:
raise NotFound, 'Fulltext key "%r" not found in catalog' %(key,) raise NotFound, 'Fulltext key "%r" not found in catalog' %(key,)
if len(key_list) > 0: if len(key_list) > 0:
self._objects[self.__class__.__name__+'/'+'full_text_key_list'] = key_list self._objects[self.__class__.__name__+'/'+'full_text_key_list'] = key_list
...@@ -3520,7 +3524,7 @@ class CatalogRequestKeyTemplateItem(BaseTemplateItem): ...@@ -3520,7 +3524,7 @@ class CatalogRequestKeyTemplateItem(BaseTemplateItem):
for key in self._archive.keys(): for key in self._archive.keys():
if key in sql_request_keys: if key in sql_request_keys:
key_list.append(key) key_list.append(key)
else: elif not self.is_bt_for_diff:
raise NotFound, 'Request key "%r" not found in catalog' %(key,) raise NotFound, 'Request key "%r" not found in catalog' %(key,)
if len(key_list) > 0: if len(key_list) > 0:
self._objects[self.__class__.__name__+'/'+'request_key_list'] = key_list self._objects[self.__class__.__name__+'/'+'request_key_list'] = key_list
...@@ -3612,7 +3616,7 @@ class CatalogMultivalueKeyTemplateItem(BaseTemplateItem): ...@@ -3612,7 +3616,7 @@ class CatalogMultivalueKeyTemplateItem(BaseTemplateItem):
for key in self._archive.keys(): for key in self._archive.keys():
if key in sql_multivalue_keys: if key in sql_multivalue_keys:
key_list.append(key) key_list.append(key)
else: elif not self.is_bt_for_diff:
raise NotFound, 'Multivalue key "%r" not found in catalog' %(key,) raise NotFound, 'Multivalue key "%r" not found in catalog' %(key,)
if len(key_list) > 0: if len(key_list) > 0:
self._objects[self.__class__.__name__+'/'+'multivalue_key_list'] = key_list self._objects[self.__class__.__name__+'/'+'multivalue_key_list'] = key_list
...@@ -3703,7 +3707,7 @@ class CatalogTopicKeyTemplateItem(BaseTemplateItem): ...@@ -3703,7 +3707,7 @@ class CatalogTopicKeyTemplateItem(BaseTemplateItem):
for key in self._archive.keys(): for key in self._archive.keys():
if key in sql_catalog_topic_search_keys: if key in sql_catalog_topic_search_keys:
key_list.append(key) key_list.append(key)
else: elif not self.is_bt_for_diff:
raise NotFound, 'Topic key "%r" not found in catalog' %(key,) raise NotFound, 'Topic key "%r" not found in catalog' %(key,)
if len(key_list) > 0: if len(key_list) > 0:
self._objects[self.__class__.__name__+'/'+'topic_key_list'] = key_list self._objects[self.__class__.__name__+'/'+'topic_key_list'] = key_list
...@@ -3794,7 +3798,7 @@ class CatalogScriptableKeyTemplateItem(BaseTemplateItem): ...@@ -3794,7 +3798,7 @@ class CatalogScriptableKeyTemplateItem(BaseTemplateItem):
for key in self._archive.keys(): for key in self._archive.keys():
if key in sql_catalog_scriptable_keys: if key in sql_catalog_scriptable_keys:
key_list.append(key) key_list.append(key)
else: elif not self.is_bt_for_diff:
raise NotFound, 'Scriptable key "%r" not found in catalog' %(key,) raise NotFound, 'Scriptable key "%r" not found in catalog' %(key,)
if len(key_list) > 0: if len(key_list) > 0:
self._objects[self.__class__.__name__+'/'+'scriptable_key_list'] = key_list self._objects[self.__class__.__name__+'/'+'scriptable_key_list'] = key_list
...@@ -3887,7 +3891,7 @@ class CatalogRoleKeyTemplateItem(BaseTemplateItem): ...@@ -3887,7 +3891,7 @@ class CatalogRoleKeyTemplateItem(BaseTemplateItem):
for key in self._archive.keys(): for key in self._archive.keys():
if key in sql_catalog_role_keys: if key in sql_catalog_role_keys:
key_list.append(key) key_list.append(key)
else: elif not self.is_bt_for_diff:
raise NotFound, 'Role key "%r" not found in catalog' %(key,) raise NotFound, 'Role key "%r" not found in catalog' %(key,)
if len(key_list) > 0: if len(key_list) > 0:
self._objects[self.__class__.__name__+'/'+'role_key_list'] = key_list self._objects[self.__class__.__name__+'/'+'role_key_list'] = key_list
...@@ -3980,7 +3984,7 @@ class CatalogLocalRoleKeyTemplateItem(BaseTemplateItem): ...@@ -3980,7 +3984,7 @@ class CatalogLocalRoleKeyTemplateItem(BaseTemplateItem):
for key in self._archive.keys(): for key in self._archive.keys():
if key in sql_catalog_local_role_keys: if key in sql_catalog_local_role_keys:
key_list.append(key) key_list.append(key)
else: elif not self.is_bt_for_diff:
raise NotFound, 'LocalRole key "%r" not found in catalog' %(key,) raise NotFound, 'LocalRole key "%r" not found in catalog' %(key,)
if len(key_list) > 0: if len(key_list) > 0:
self._objects[self.__class__.__name__+'/'+'local_role_key_list'] = key_list self._objects[self.__class__.__name__+'/'+'local_role_key_list'] = key_list
...@@ -4569,7 +4573,10 @@ Business Template is a set of definitions, such as skins, portal types and categ ...@@ -4569,7 +4573,10 @@ Business Template is a set of definitions, such as skins, portal types and categ
# Build each part # Build each part
for item_name in self._item_name_list: for item_name in self._item_name_list:
getattr(self, item_name).build(self) item = getattr(self, item_name)
if self.getBtForDiff():
item.is_bt_for_diff = 1
item.build(self)
build = WorkflowMethod(build) build = WorkflowMethod(build)
...@@ -4638,7 +4645,7 @@ Business Template is a set of definitions, such as skins, portal types and categ ...@@ -4638,7 +4645,7 @@ Business Template is a set of definitions, such as skins, portal types and categ
bt2 = self.portal_templates.manage_clone(ob=installed_bt, id=INSTALLED_BT_FOR_DIFF) bt2 = self.portal_templates.manage_clone(ob=installed_bt, id=INSTALLED_BT_FOR_DIFF)
# update portal types properties to get last modifications # update portal types properties to get last modifications
bt2.getPortalTypesProperties() bt2.getPortalTypesProperties()
bt2.edit(description='tmp bt generated for diff') bt2.edit(description='tmp bt generated for diff', bt_for_diff=1)
bt2.build() bt2.build()
installed_bt = bt2 installed_bt = bt2
......
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