Commit 42f263ae authored by Arnaud Fontaine's avatar Arnaud Fontaine

ZODB Components: Do not automatically validate when importing from FS as...

ZODB Components: Do not automatically validate when importing from FS as imports have to be adjusted manually.
parent 6980d7df
......@@ -6597,7 +6597,9 @@ Business Template is a set of definitions, such as skins, portal types and categ
if list_selection_name is not None:
message = (
"All components were successfully imported from filesystem to ZODB. "
"You can now delete them from your instance home and Products.")
"Please note that imported {Document,Interfaces,Mixin,Tool Components} "
"have not been validated automatically as imports must probably be "
"adjusted before deleting them from the filesystem.")
if still_used_list_dict:
message = (
......
......@@ -8225,7 +8225,14 @@ class _LocalTemplateItemMixin:
self.assertEqual(component.getTextContent(), sequence['document_data'])
self.assertEqual(component.getPortalType(), self.component_portal_type)
self.assertEqual(component.getSourceReference(), sequence['document_source_reference'])
self.assertEqual(component.getValidationState(), 'validated')
if self.component_portal_type in ('Extension Component', 'Test Component'):
self.assertEqual(component.getValidationState(), 'validated')
else:
# Not validated automatically
self.assertEqual(component.getValidationState(), 'draft')
component.validate()
self.tic()
self.assertEqual(component.getValidationState(), 'validated')
sequence.edit(document_id=component_id)
def test_BusinessTemplateWithZodbDocumentMigrated(self):
......
......@@ -48,6 +48,8 @@ class ExtensionComponent(ComponentMixin, TextContentHistoryMixin):
security = ClassSecurityInfo()
security.declareObjectProtected(Permissions.AccessContentsInformation)
do_validate_on_import_from_filesystem = True
@staticmethod
def _getFilesystemPath():
import os.path
......
......@@ -49,6 +49,8 @@ class TestComponent(ComponentMixin, TextContentHistoryMixin):
security = ClassSecurityInfo()
security.declareObjectProtected(Permissions.AccessContentsInformation)
do_validate_on_import_from_filesystem = True
@staticmethod
def _getFilesystemPath():
import os.path
......
......@@ -342,6 +342,13 @@ class ComponentMixin(PropertyRecordableMixin, Base):
"""
return self.getTextContent()
# Whether ZODB Components is going to be validated or not should depend on
# its types because it is fine to validate '{Test,Extension} Component' as
# it not going to break anything but not for {Document,Interface,Mixin,Tool}
# Components...
do_validate_on_import_from_filesystem = False
security.declareProtected(Permissions.ModifyPortalContent,
'importFromFilesystem')
@classmethod
......@@ -388,7 +395,9 @@ class ComponentMixin(PropertyRecordableMixin, Base):
from Products.DCWorkflow.DCWorkflow import ValidationFailed
raise ValidationFailed(consistency_message_list)
new_component.validate()
if cls.do_validate_on_import_from_filesystem:
new_component.validate()
return new_component
InitializeClass(ComponentMixin)
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