Commit 21c8f6c5 authored by Arnaud Fontaine's avatar Arnaud Fontaine

ZODB Components: Revert "Also, allow developer to call validate action from...

ZODB Components: Revert "Also, allow developer to call validate action from 'modified' state to handle import use case" (part of 1cb2dc4c).

This was badly implemented as it didn't handle the following use cases:
  * {draft,invalidated} => validated.
  * clearRecordedPropertyDict() was not called on re-validate.

For now, re-validate through modifying {text_content,reference,version}.
parent bf625f3a
Pipeline #6457 failed with stage
obj = state_change['object']
# User explicitely wants to validate again (example use case: import-error
# on ZODB Components which have now been fixed)
if obj.getValidationState() == 'modified':
obj.checkSourceCode()
obj.Base_checkConsistency()
state_change['object'].Base_checkConsistency()
......@@ -26,7 +26,6 @@
<string>invalidate_action</string>
<string>modify</string>
<string>validate</string>
<string>validate_action</string>
</tuple>
</value>
</item>
......
obj = state_change['object']
obj.checkSourceCode()
if not obj.getTextContentErrorMessageList() and obj.getValidationState() == 'modified':
error_list = []
warning_list = []
for message_dict in obj.checkSourceCode():
message = '%s:%3d,%3d: %s' % (message_dict['type'],
message_dict['row'],
message_dict['column'],
message_dict['text'])
if message_dict['type'] in ('F', 'E'):
error_list.append(message)
else:
warning_list.append(message)
obj.setTextContentWarningMessageList(warning_list)
obj.setTextContentErrorMessageList(error_list)
if not error_list and obj.getValidationState() == 'modified':
obj.checkConsistencyAndValidate()
......@@ -309,22 +309,7 @@ class ComponentMixin(PropertyRecordableMixin, Base):
Check Component source code through Pylint or compile() builtin if not
available
"""
error_list = []
warning_list = []
for message_dict in checkPythonSourceCode(self.getTextContent(),
self.getPortalType()):
message = '%s:%3d,%3d: %s' % (message_dict['type'],
message_dict['row'],
message_dict['column'],
message_dict['text'])
if message_dict['type'] in ('F', 'E'):
error_list.append(message)
else:
warning_list.append(message)
self.setTextContentWarningMessageList(warning_list)
self.setTextContentErrorMessageList(error_list)
return checkPythonSourceCode(self.getTextContent(), self.getPortalType())
security.declareProtected(Permissions.ModifyPortalContent, 'PUT')
def PUT(self, REQUEST, RESPONSE):
......
......@@ -2272,8 +2272,8 @@ ValidationFailed('anything')
self.assertEqual(imported_component1.getValidationState(), 'validated')
self.assertEqual(imported_component2.getValidationState(), 'validated')
# 2) Then validate again the main one
self.portal.portal_workflow.doActionFor(component, 'validate_action')
# 2) Then modify the main one so that it automatically 'validate'
component.setTextContent(component.getTextContent() + '\n')
self.tic()
self._assertAstroidCacheContent(
must_be_in_cache_set={'%s' % namespace,
......
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