Commit f1b7b62c authored by Jérome Perrin's avatar Jérome Perrin

Display the constraint relative URL in checkConsistency

parent 968cd504
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
############################################################################## ##############################################################################
import zope.interface import zope.interface
from Acquisition import aq_base
from Products.PythonScripts.Utility import allow_class from Products.PythonScripts.Utility import allow_class
from Products.ERP5Type.ObjectMessage import ObjectMessage from Products.ERP5Type.ObjectMessage import ObjectMessage
...@@ -36,7 +37,7 @@ class ConsistencyMessage(ObjectMessage): ...@@ -36,7 +37,7 @@ class ConsistencyMessage(ObjectMessage):
""" """
Consistency Message is used for notifications to user after checkConsistency. Consistency Message is used for notifications to user after checkConsistency.
""" """
zope.interface.implements( interfaces.IConsistencyMessage, ) zope.interface.implements( interfaces.IConsistencyMessage, )
def __init__(self, constraint, object_relative_url='', def __init__(self, constraint, object_relative_url='',
...@@ -47,6 +48,16 @@ class ConsistencyMessage(ObjectMessage): ...@@ -47,6 +48,16 @@ class ConsistencyMessage(ObjectMessage):
ObjectMessage.__init__(self, object_relative_url, message, mapping) ObjectMessage.__init__(self, object_relative_url, message, mapping)
self.description = constraint.description self.description = constraint.description
self.class_name = constraint.__class__.__name__ self.class_name = constraint.__class__.__name__
# keep track of the relative URL of the constraint to have it included in
# the message
constraint_relative_url = getattr(aq_base(constraint), 'relative_url', None)
if not constraint_relative_url:
try:
constraint_relative_url = constraint.getRelativeUrl()
except AttributeError:
constraint_relative_url = constraint.id
self.constraint_relative_url = constraint_relative_url
self.__dict__.update(kw) self.__dict__.update(kw)
def __getitem__(self, key): def __getitem__(self, key):
...@@ -66,8 +77,9 @@ class ConsistencyMessage(ObjectMessage): ...@@ -66,8 +77,9 @@ class ConsistencyMessage(ObjectMessage):
return self.getTranslatedMessage() return self.getTranslatedMessage()
def __repr__(self): def __repr__(self):
return "<ERP5Type.ConsistencyMessage for %s on %s (message: %s)>" % ( return "<ERP5Type.ConsistencyMessage for %s %s on %s (message: %s)>" % (
self.class_name, self.object_relative_url, self.getTranslatedMessage()) self.class_name, self.constraint_relative_url,
self.object_relative_url, self.getTranslatedMessage())
allow_class(ConsistencyMessage) allow_class(ConsistencyMessage)
...@@ -201,4 +201,8 @@ class ConstraintMixin(IdAsReferenceMixin('_constraint'), Predicate): ...@@ -201,4 +201,8 @@ class ConstraintMixin(IdAsReferenceMixin('_constraint'), Predicate):
# this(accessor_holder is on-memory object and is kept beyond transaction) # this(accessor_holder is on-memory object and is kept beyond transaction)
# then ConnectionStateError occurs after a long time. # then ConnectionStateError occurs after a long time.
import copy import copy
accessor_holder.constraints.append(copy.deepcopy(self.aq_base)) constraint_definition = copy.deepcopy(self.aq_base)
# note the relative url of this constraint to display it later in
# checkConsistency messages
constraint_definition.relative_url = self.getRelativeUrl()
accessor_holder.constraints.append(constraint_definition)
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