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

fix stx format for HelpSys



git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@14591 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent b7478769
......@@ -26,6 +26,9 @@
#
##############################################################################
"""Constraint Interface.
"""
try:
from Interface import Interface
except ImportError:
......@@ -41,7 +44,7 @@ class Constraint(Interface):
A property sheet can contain _constraints slot ( just like _properties and
_categories ). _constraints is a list of constraint definition represented
as dictionnaries, for example we can have:
as dictionnaries, for example we can have::
_constraints = (
{ # we need to have an id
......@@ -67,7 +70,7 @@ class Constraint(Interface):
)
Those constraint definition parameters will be available from the Constraint
instance as `self.constraint_definition` (a dict).
instance as 'self.constraint_definition' (a dict).
Calling checkConsistency() method on any ERP5Type document will check all
constraint defined on this document. If the document is a subclass of
......@@ -80,26 +83,27 @@ class Constraint(Interface):
"""
def checkConsistency(obj, fixit=0):
"""This method checks the consistency of object `obj`, and fix errors if
the argument `fixit` is true. Not all constraint have to support error
"""This method checks the consistency of object 'obj', and fix errors if
the argument 'fixit' is true. Not all constraint have to support error
repairing, in that case, simply ignore the fixit parameter.
This method should return a list of errors, which are a list for now.
"""
def _generateError(obj, error_message, mapping={}):
"""Generate an error for `obj` with the corresponding `error_message`.
"""Generate an error for 'obj' with the corresponding 'error_message'.
This method is usefull for Constraint authors, in case of an error, they
can simply call:
can simply call::
>>> if something_is_wrong:
>>> errors.append(self._generateError(obj, 'Something is wrong !')
Then this message ('Something is wrong !') will be translated when the
Then this message ("Something is wrong !") will be translated when the
caller of document.checkConsistency() calls getTranslatedMessage() on
ConsistencyMessage instances returned by checkConsistency.
The implementation uses ERP5Type's Messages, so it's possible to use a
`mapping` for substitution, like this:
'mapping' for substitution, like this::
>>> if something_is_wrong:
>>> errors.append(self._generateError(obj,
... 'Something is wrong: ${wrong_thing}',
......
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