Commit a2443d9f authored by Yoshinori Okuji's avatar Yoshinori Okuji

Remove _light_archive, and make it compatible with Category as well as Base Category.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@3395 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 09acd957
...@@ -200,9 +200,6 @@ class CategoryTemplateItem(ObjectTemplateItem): ...@@ -200,9 +200,6 @@ class CategoryTemplateItem(ObjectTemplateItem):
def __init__(self, id_list, **kw): def __init__(self, id_list, **kw):
ObjectTemplateItem.__init__(self, id_list, **kw) ObjectTemplateItem.__init__(self, id_list, **kw)
self._light_archive = PersistentMapping()
for id in id_list:
self._light_archive[id] = None
tool_id = 'portal_categories' tool_id = 'portal_categories'
id_list = self._archive.keys() id_list = self._archive.keys()
self._archive.clear() self._archive.clear()
...@@ -226,15 +223,6 @@ class CategoryTemplateItem(ObjectTemplateItem): ...@@ -226,15 +223,6 @@ class CategoryTemplateItem(ObjectTemplateItem):
category_copy.manage_delObjects(list(id_list)) category_copy.manage_delObjects(list(id_list))
self._archive[relative_url] = category_copy self._archive[relative_url] = category_copy
category_copy.wl_clearLocks() category_copy.wl_clearLocks()
# No store attributes for light install
mapping = PersistentMapping()
mapping['id'] = category.getId()
property_list = PersistentMapping()
for property in [x for x in category.propertyIds() if x not in ('id','uid')]:
property_list[property] = category.getProperty(property,evaluate=0)
mapping['property_list'] = property_list
#mapping['title'] = category.getTitle()
self._light_archive[category_id] = mapping
def install(self, context, light_install = 0, **kw): def install(self, context, light_install = 0, **kw):
BaseTemplateItem.install(self, context, **kw) BaseTemplateItem.install(self, context, **kw)
...@@ -244,13 +232,19 @@ class CategoryTemplateItem(ObjectTemplateItem): ...@@ -244,13 +232,19 @@ class CategoryTemplateItem(ObjectTemplateItem):
if light_install==0: if light_install==0:
ObjectTemplateItem.install(self, context, **kw) ObjectTemplateItem.install(self, context, **kw)
else: else:
for category_id in self._light_archive.keys(): for relative_url,object in self._archive.items():
if category_id in category_tool.objectIds(): # Wrap the object by an aquisition wrapper for _aq_dynamic.
raise TemplateConflictError, 'the category %s already exists' % category_id object = object.__of__(category_tool)
category = category_tool.newContent(portal_type='Base Category',id=category_id) container_path = relative_url.split('/')[0:-1]
property_list = self._light_archive[category_id]['property_list'] category_id = relative_url.split('/')[-1]
for property,value in property_list.items(): container = category_tool.unrestrictedTraverse(container_path)
category.setProperty(property,value) container_ids = container.objectIds()
if category_id in container_ids: # Object already exists
self._backupObject(container, category_id)
category = container.newContent(portal_type=object.getPortalType(), id=category_id)
for property in object.propertyIds():
if property not in ('id', 'uid'):
category.setProperty(property, object.getProperty(property, evaluate=0))
class SkinTemplateItem(ObjectTemplateItem): class SkinTemplateItem(ObjectTemplateItem):
......
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