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