Commit 4e9da49e authored by Arnaud Fontaine's avatar Arnaud Fontaine

Use existing error_message workflow variable of component_validation_workflow.

Before, ConsistencyMessage were stored into a separate workflow variable,
instead of using error_message workflow variable which contains instances of
Message.
parent 0b3fdb3f
...@@ -56,6 +56,14 @@ ...@@ -56,6 +56,14 @@
<key> <string>tales</string> </key> <key> <string>tales</string> </key>
<value> <value>
<dictionary> <dictionary>
<item>
<key> <string>css_class</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>editable</string> </key>
<value> <string></string> </value>
</item>
<item> <item>
<key> <string>enabled</string> </key> <key> <string>enabled</string> </key>
<value> <value>
...@@ -70,10 +78,18 @@ ...@@ -70,10 +78,18 @@
<key> <string>form_id</string> </key> <key> <string>form_id</string> </key>
<value> <string></string> </value> <value> <string></string> </value>
</item> </item>
<item>
<key> <string>height</string> </key>
<value> <string></string> </value>
</item>
<item> <item>
<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>
...@@ -127,7 +143,7 @@ ...@@ -127,7 +143,7 @@
<dictionary> <dictionary>
<item> <item>
<key> <string>_text</string> </key> <key> <string>_text</string> </key>
<value> <string>python: here.getValidationState() == \'modified\'</string> </value> <value> <string>here/hasErrorMessageList</string> </value>
</item> </item>
</dictionary> </dictionary>
</pickle> </pickle>
......
2012-02-29 arnaud.fontaine
* Display error messages in Component_view which may have been raised when validating a Component in draft state.
2012-02-29 arnaud.fontaine 2012-02-29 arnaud.fontaine
* Add portal_components to keep path list. * Add portal_components to keep path list.
......
41018 41019
\ No newline at end of file \ No newline at end of file
...@@ -239,13 +239,29 @@ class ComponentMixin(PropertyRecordableMixin, Base): ...@@ -239,13 +239,29 @@ class ComponentMixin(PropertyRecordableMixin, Base):
error_list = self.checkConsistency() error_list = self.checkConsistency()
if error_list: if error_list:
workflow = self.workflow_history['component_validation_workflow'][-1] workflow = self.workflow_history['component_validation_workflow'][-1]
workflow['error_list'] = error_list
# When checking consistency with validate_action, messages are stored
# into error_message workflow attribute as Message instances
workflow['error_message'] = [error.getMessage() for error in error_list]
else: else:
for property_name in self._recorded_property_name_tuple: for property_name in self._recorded_property_name_tuple:
self.clearRecordedProperty(property_name) self.clearRecordedProperty(property_name)
self.validate() self.validate()
security.declareProtected(Permissions.AccessContentsInformation,
'getErrorMessageList')
def hasErrorMessageList(self):
"""
Check whether there are error messages, useful to display errors in the UI
without calling getErrorMessageList() which translates error messages
"""
try:
self.workflow_history['component_validation_workflow'][-1]['error_message']
return True
except KeyError:
return False
security.declareProtected(Permissions.AccessContentsInformation, security.declareProtected(Permissions.AccessContentsInformation,
'getErrorMessageList') 'getErrorMessageList')
def getErrorMessageList(self): def getErrorMessageList(self):
...@@ -254,8 +270,8 @@ class ComponentMixin(PropertyRecordableMixin, Base): ...@@ -254,8 +270,8 @@ class ComponentMixin(PropertyRecordableMixin, Base):
the Component has been modified after being validated once the Component has been modified after being validated once
""" """
current_workflow = self.workflow_history['component_validation_workflow'][-1] current_workflow = self.workflow_history['component_validation_workflow'][-1]
return [str(error.getTranslatedMessage()) return [error.translate()
for error in current_workflow.get('error_list', [])] for error in current_workflow.get('error_message', [])]
security.declareProtected(Permissions.ModifyPortalContent, 'load') security.declareProtected(Permissions.ModifyPortalContent, 'load')
def load(self, namespace_dict={}, validated_only=False, text_content=None): def load(self, namespace_dict={}, validated_only=False, text_content=None):
......
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