Commit 819eca53 authored by Vincent Pelletier's avatar Vincent Pelletier

Remove LocalConfiguration and update all users. It was only used as an...

Remove LocalConfiguration and update all users. It was only used as an acquisition context and caused needless (because never used afterward) modification of persistent objects at business template installation. This should save some disk space and increase performances a bit.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@19374 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 9f790900
...@@ -4453,15 +4453,12 @@ Business Template is a set of definitions, such as skins, portal types and categ ...@@ -4453,15 +4453,12 @@ Business Template is a set of definitions, such as skins, portal types and categ
modified_object_list.update({path : ['New', item.__class__.__name__[:-12]]}) modified_object_list.update({path : ['New', item.__class__.__name__[:-12]]})
return modified_object_list return modified_object_list
# get the list of modified and new object
self.portal_templates.updateLocalConfiguration(self, **kw)
local_configuration = self.portal_templates.getLocalConfiguration(self)
for item_name in self._item_name_list: for item_name in self._item_name_list:
new_item = getattr(self, item_name, None) new_item = getattr(self, item_name, None)
old_item = getattr(installed_bt, item_name, None) old_item = getattr(installed_bt, item_name, None)
if new_item is not None: if new_item is not None:
if old_item is not None and hasattr(old_item, '_objects'): if old_item is not None and hasattr(old_item, '_objects'):
modified_object = new_item.preinstall(context=local_configuration, installed_bt=old_item) modified_object = new_item.preinstall(context=self, installed_bt=old_item)
if len(modified_object) > 0: if len(modified_object) > 0:
modified_object_list.update(modified_object) modified_object_list.update(modified_object)
else: else:
...@@ -4524,11 +4521,6 @@ Business Template is a set of definitions, such as skins, portal types and categ ...@@ -4524,11 +4521,6 @@ Business Template is a set of definitions, such as skins, portal types and categ
gen.setupWorkflow(site) gen.setupWorkflow(site)
return return
# Update local dictionary containing all setup parameters
# This may include mappings
self.portal_templates.updateLocalConfiguration(self, **kw)
local_configuration = self.portal_templates.getLocalConfiguration(self)
# always created a trash bin because we may to save object already present # always created a trash bin because we may to save object already present
# but not in a previous business templates apart at creation of a new site # but not in a previous business templates apart at creation of a new site
if trash_tool is not None and (len(object_to_update) > 0 or len(self.portal_templates.objectIds()) > 1): if trash_tool is not None and (len(object_to_update) > 0 or len(self.portal_templates.objectIds()) > 1):
...@@ -4541,7 +4533,7 @@ Business Template is a set of definitions, such as skins, portal types and categ ...@@ -4541,7 +4533,7 @@ Business Template is a set of definitions, such as skins, portal types and categ
for item_name in self._item_name_list: for item_name in self._item_name_list:
item = getattr(self, item_name, None) item = getattr(self, item_name, None)
if item is not None: if item is not None:
item.install(local_configuration, force=force, object_to_update=object_to_update, trashbin=trashbin) item.install(self, force=force, object_to_update=object_to_update, trashbin=trashbin)
# update catalog if necessary # update catalog if necessary
if force and self.isCatalogUpdatable(): if force and self.isCatalogUpdatable():
...@@ -4571,7 +4563,7 @@ Business Template is a set of definitions, such as skins, portal types and categ ...@@ -4571,7 +4563,7 @@ Business Template is a set of definitions, such as skins, portal types and categ
for item_name in installed_bt._item_name_list: for item_name in installed_bt._item_name_list:
item = getattr(installed_bt, item_name, None) item = getattr(installed_bt, item_name, None)
if item is not None: if item is not None:
item.remove(local_configuration, remove_object_dict=remove_object_dict, trashbin=trashbin) item.remove(self, remove_object_dict=remove_object_dict, trashbin=trashbin)
# update tools if necessary # update tools if necessary
...@@ -4630,16 +4622,12 @@ Business Template is a set of definitions, such as skins, portal types and categ ...@@ -4630,16 +4622,12 @@ Business Template is a set of definitions, such as skins, portal types and categ
This is similar to uninstall, but different in that this does This is similar to uninstall, but different in that this does
not remove all items. not remove all items.
""" """
# Update local dictionary containing all setup parameters
# This may include mappings
self.portal_templates.updateLocalConfiguration(self, **kw)
local_configuration = self.portal_templates.getLocalConfiguration(self)
# Trash everything # Trash everything
for item_name in self._item_name_list[::-1]: for item_name in self._item_name_list[::-1]:
item = getattr(self, item_name, None) item = getattr(self, item_name, None)
if item is not None: if item is not None:
item.trash( item.trash(
local_configuration, self,
getattr(new_bt, item_name)) getattr(new_bt, item_name))
security.declareProtected(Permissions.ManagePortal, 'uninstall') security.declareProtected(Permissions.ManagePortal, 'uninstall')
...@@ -4647,16 +4635,12 @@ Business Template is a set of definitions, such as skins, portal types and categ ...@@ -4647,16 +4635,12 @@ Business Template is a set of definitions, such as skins, portal types and categ
""" """
For uninstall based on paramaters provided in **kw For uninstall based on paramaters provided in **kw
""" """
# Update local dictionary containing all setup parameters
# This may include mappings
self.portal_templates.updateLocalConfiguration(self, **kw)
local_configuration = self.portal_templates.getLocalConfiguration(self)
# Uninstall everything # Uninstall everything
# Trash everything # Trash everything
for item_name in self._item_name_list[::-1]: for item_name in self._item_name_list[::-1]:
item = getattr(self, item_name, None) item = getattr(self, item_name, None)
if item is not None: if item is not None:
item.uninstall(local_configuration) item.uninstall(self)
# It is better to clear cache because the uninstallation of a # It is better to clear cache because the uninstallation of a
# template deletes many things from the portal. # template deletes many things from the portal.
self.getPortalObject().portal_caches.clearAllCache() self.getPortalObject().portal_caches.clearAllCache()
......
...@@ -74,16 +74,6 @@ class BusinessTemplateIsMeta(Exception): ...@@ -74,16 +74,6 @@ class BusinessTemplateIsMeta(Exception):
""" """
pass pass
class LocalConfiguration(Implicit):
"""
Contains local configuration information
"""
def __init__(self, **kw):
self.__dict__.update(kw)
def update(self, **kw):
self.__dict__.update(kw)
class TemplateTool (BaseTool): class TemplateTool (BaseTool):
""" """
TemplateTool manages Business Templates. TemplateTool manages Business Templates.
...@@ -161,32 +151,6 @@ class TemplateTool (BaseTool): ...@@ -161,32 +151,6 @@ class TemplateTool (BaseTool):
return "file://%s/" % pathname2url( return "file://%s/" % pathname2url(
os.path.join(getConfiguration().instancehome, 'bt5')) os.path.join(getConfiguration().instancehome, 'bt5'))
def updateLocalConfiguration(self, template, **kw):
"""
Call the update method on the configuration, create if it doesn't
exists.
"""
template_id = template.getId()
if getattr(self, '_local_configuration', None) is None:
self._local_configuration = PersistentMapping()
if not self._local_configuration.has_key(template_id):
self._local_configuration[template_id] = LocalConfiguration(**kw)
else:
self._local_configuration[template_id].update(**kw)
def getLocalConfiguration(self, template):
"""
Return the configuration for the given business template, or None if
it's not defined.
"""
template_id = template.getId()
if getattr(self, '_local_configuration', None) is None:
self._local_configuration = PersistentMapping()
local_configuration = self._local_configuration.get(template_id, None)
if local_configuration is not None:
return local_configuration.__of__(template)
return None
security.declareProtected( 'Import/Export objects', 'save' ) security.declareProtected( 'Import/Export objects', 'save' )
def save(self, business_template, REQUEST=None, RESPONSE=None): def save(self, business_template, REQUEST=None, RESPONSE=None):
""" """
......
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