Commit e6232b04 authored by Arnaud Fontaine's avatar Arnaud Fontaine

When migrating Components from filesystem to ZODB, allow to specify version per Component.

parent 476ce70e
......@@ -5904,58 +5904,44 @@ Business Template is a set of definitions, such as skins, portal types and categ
security.declareProtected(Permissions.ManagePortal,
'migrateSourceCodeFromFilesystem')
def migrateSourceCodeFromFilesystem(self,
version_priority,
component_portal_type_dict,
erase_existing=False,
**kw):
if not component_portal_type_dict:
return {}
component_tool = self.getPortalObject().portal_components
failed_import_dict = {}
# XXX-arnau: dirty because of copy/paste but will be refactor
# later with Products anyway...
from Products.ERP5Type.Core.DocumentComponent import DocumentComponent
document_id_list = self.getTemplateDocumentIdList()
for i, reference in enumerate(document_id_list):
try:
obj = DocumentComponent.importFromFilesystem(component_tool,
def migrate(component_dict, component_class, template_id_list_method):
migrated_id_list = []
for reference, version in component_dict.iteritems():
try:
obj = component_class.importFromFilesystem(component_tool,
reference,
version_priority,
version,
erase_existing)
except Exception, e:
failed_import_dict[reference] = str(e)
else:
document_id_list[i] = obj.getId()
self.setTemplateDocumentIdList(document_id_list)
except Exception, e:
failed_import_dict[reference] = str(e)
else:
migrated_id_list.append(obj.getId())
from Products.ERP5Type.Core.ExtensionComponent import ExtensionComponent
extension_id_list = self.getTemplateExtensionIdList()
for i, reference in enumerate(extension_id_list):
try:
obj = ExtensionComponent.importFromFilesystem(component_tool,
reference,
version_priority,
erase_existing)
except Exception, e:
failed_import_dict[reference] = str(e)
else:
extension_id_list[i] = obj.getId()
if migrated_id_list:
template_id_list_method(migrated_id_list)
self.setTemplateExtensionIdList(extension_id_list)
component_dict = component_portal_type_dict.get('Document Component')
if component_dict:
from Products.ERP5Type.Core.DocumentComponent import DocumentComponent
migrate(component_dict, DocumentComponent, self.setTemplateDocumentIdList)
from Products.ERP5Type.Core.TestComponent import TestComponent
test_id_list = self.getTemplateTestIdList()
for i, reference in enumerate(test_id_list):
try:
obj = TestComponent.importFromFilesystem(component_tool,
reference,
version_priority,
erase_existing)
except Exception, e:
failed_import_dict[reference] = str(e)
else:
test_id_list[i] = obj.getId()
component_dict = component_portal_type_dict.get('Extension Component')
if component_dict:
from Products.ERP5Type.Core.ExtensionComponent import ExtensionComponent
migrate(component_dict, ExtensionComponent, self.setTemplateExtensionIdList)
self.setTemplateTestIdList(test_id_list)
component_dict = component_portal_type_dict.get('Test Component')
if component_dict:
from Products.ERP5Type.Core.TestComponent import TestComponent
migrate(component_dict, TestComponent, self.setTemplateTestIdList)
return failed_import_dict
......
......@@ -50,7 +50,19 @@
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>failed_import_dict = context.migrateSourceCodeFromFilesystem(version_priority, erase_existing, **kw)\n
<value> <string>request = context.REQUEST\n
object_list = context.portal_selections.getSelectionValueList(selection_name=request[\'listbox_list_selection_name\'],\n
context=context,\n
REQUEST=request)\n
\n
listbox_dict = request[\'listbox\']\n
\n
component_dict = {}\n
for object in object_list:\n
component_dict.setdefault(object.destination_portal_type,\n
{})[object.getUid()] = listbox_dict[object.getUrl()][\'version_item_list\']\n
\n
failed_import_dict = context.migrateSourceCodeFromFilesystem(component_dict, erase_existing, **kw)\n
\n
if failed_import_dict:\n
failed_import_formatted_list = []\n
......@@ -67,7 +79,7 @@ return context.Base_redirect(\'view\',\n
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>version_priority, erase_existing=False, **kw</string> </value>
<value> <string>erase_existing=False, **kw</string> </value>
</item>
<item>
<key> <string>id</string> </key>
......
......@@ -88,14 +88,15 @@
<item>
<key> <string>hidden</string> </key>
<value>
<list/>
<list>
<string>listbox_version_item_list</string>
</list>
</value>
</item>
<item>
<key> <string>left</string> </key>
<value>
<list>
<string>my_version_priority</string>
<string>my_erase_existing</string>
</list>
</value>
......
......@@ -409,6 +409,10 @@
<string>destination_portal_type</string>
<string>Destination Portal Type</string>
</tuple>
<tuple>
<string>version_item_list</string>
<string>Version</string>
</tuple>
</list>
</value>
</item>
......@@ -457,7 +461,12 @@
<item>
<key> <string>editable_columns</string> </key>
<value>
<list/>
<list>
<tuple>
<string>version_item_list</string>
<string>Version</string>
</tuple>
</list>
</value>
</item>
<item>
......@@ -550,7 +559,7 @@
</item>
<item>
<key> <string>selection_name</string> </key>
<value> <string>business_template_migrate_all_component_from_filesystem_view_component_list_selection</string> </value>
<value> <string>business_template_migrate_source_code_from_filesystem_view_component_list_selection</string> </value>
</item>
<item>
<key> <string>sort</string> </key>
......
......@@ -10,15 +10,15 @@
<key> <string>delegated_list</string> </key>
<value>
<list>
<string>first_item</string>
<string>items</string>
<string>size</string>
<string>title</string>
</list>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>my_version_priority</string> </value>
<value> <string>listbox_version_item_list</string> </value>
</item>
<item>
<key> <string>message_values</string> </key>
......@@ -72,10 +72,6 @@
<key> <string>target</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
......@@ -87,10 +83,6 @@
<key> <string>field_id</string> </key>
<value> <string>my_list_field</string> </value>
</item>
<item>
<key> <string>first_item</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string>Base_viewFieldLibrary</string> </value>
......@@ -101,6 +93,10 @@
<list/>
</value>
</item>
<item>
<key> <string>size</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string>Click to edit the target</string> </value>
......
2012-03-06 arnaud.fontaine
* Allow to specify version per Components in migration view.
2012-03-06 arnaud.fontaine
* Show Component versions defined on the BusinessTemplate in ZODB Migration view.
......
41028
\ No newline at end of file
41029
\ No newline at end of file
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