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
modified_object_list.update({path : ['New', item.__class__.__name__[:-12]]})
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:
new_item = getattr(self, item_name, None)
old_item = getattr(installed_bt, item_name, None)
if new_item is not None:
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:
modified_object_list.update(modified_object)
else:
......@@ -4524,11 +4521,6 @@ Business Template is a set of definitions, such as skins, portal types and categ
gen.setupWorkflow(site)
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
# 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):
......@@ -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:
item = getattr(self, item_name, 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
if force and self.isCatalogUpdatable():
......@@ -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:
item = getattr(installed_bt, item_name, 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
......@@ -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
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
for item_name in self._item_name_list[::-1]:
item = getattr(self, item_name, None)
if item is not None:
item.trash(
local_configuration,
self,
getattr(new_bt, item_name))
security.declareProtected(Permissions.ManagePortal, 'uninstall')
......@@ -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
"""
# 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
# Trash everything
for item_name in self._item_name_list[::-1]:
item = getattr(self, item_name, None)
if item is not None:
item.uninstall(local_configuration)
item.uninstall(self)
# It is better to clear cache because the uninstallation of a
# template deletes many things from the portal.
self.getPortalObject().portal_caches.clearAllCache()
......
......@@ -74,16 +74,6 @@ class BusinessTemplateIsMeta(Exception):
"""
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):
"""
TemplateTool manages Business Templates.
......@@ -161,32 +151,6 @@ class TemplateTool (BaseTool):
return "file://%s/" % pathname2url(
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' )
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