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 ...@@ -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: if list_selection_name is not None:
message = ( message = (
"All components were successfully imported from filesystem to ZODB. " "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: if still_used_list_dict:
message = ( message = (
......
...@@ -8225,6 +8225,13 @@ class _LocalTemplateItemMixin: ...@@ -8225,6 +8225,13 @@ class _LocalTemplateItemMixin:
self.assertEqual(component.getTextContent(), sequence['document_data']) self.assertEqual(component.getTextContent(), sequence['document_data'])
self.assertEqual(component.getPortalType(), self.component_portal_type) self.assertEqual(component.getPortalType(), self.component_portal_type)
self.assertEqual(component.getSourceReference(), sequence['document_source_reference']) self.assertEqual(component.getSourceReference(), sequence['document_source_reference'])
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') self.assertEqual(component.getValidationState(), 'validated')
sequence.edit(document_id=component_id) sequence.edit(document_id=component_id)
......
...@@ -48,6 +48,8 @@ class ExtensionComponent(ComponentMixin, TextContentHistoryMixin): ...@@ -48,6 +48,8 @@ class ExtensionComponent(ComponentMixin, TextContentHistoryMixin):
security = ClassSecurityInfo() security = ClassSecurityInfo()
security.declareObjectProtected(Permissions.AccessContentsInformation) security.declareObjectProtected(Permissions.AccessContentsInformation)
do_validate_on_import_from_filesystem = True
@staticmethod @staticmethod
def _getFilesystemPath(): def _getFilesystemPath():
import os.path import os.path
......
...@@ -49,6 +49,8 @@ class TestComponent(ComponentMixin, TextContentHistoryMixin): ...@@ -49,6 +49,8 @@ class TestComponent(ComponentMixin, TextContentHistoryMixin):
security = ClassSecurityInfo() security = ClassSecurityInfo()
security.declareObjectProtected(Permissions.AccessContentsInformation) security.declareObjectProtected(Permissions.AccessContentsInformation)
do_validate_on_import_from_filesystem = True
@staticmethod @staticmethod
def _getFilesystemPath(): def _getFilesystemPath():
import os.path import os.path
......
...@@ -342,6 +342,13 @@ class ComponentMixin(PropertyRecordableMixin, Base): ...@@ -342,6 +342,13 @@ class ComponentMixin(PropertyRecordableMixin, Base):
""" """
return self.getTextContent() 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, security.declareProtected(Permissions.ModifyPortalContent,
'importFromFilesystem') 'importFromFilesystem')
@classmethod @classmethod
...@@ -388,7 +395,9 @@ class ComponentMixin(PropertyRecordableMixin, Base): ...@@ -388,7 +395,9 @@ class ComponentMixin(PropertyRecordableMixin, Base):
from Products.DCWorkflow.DCWorkflow import ValidationFailed from Products.DCWorkflow.DCWorkflow import ValidationFailed
raise ValidationFailed(consistency_message_list) raise ValidationFailed(consistency_message_list)
if cls.do_validate_on_import_from_filesystem:
new_component.validate() new_component.validate()
return new_component return new_component
InitializeClass(ComponentMixin) 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