Commit 0ee3f476 authored by Jérome Perrin's avatar Jérome Perrin

ERP5Form: implement a basic _checkConsistency for ProxyField WIP

parent cb5aeb8f
Pipeline #13290 running with stage
...@@ -1386,6 +1386,13 @@ class ERP5Form(Base, ZMIForm, ZopePageTemplate): ...@@ -1386,6 +1386,13 @@ class ERP5Form(Base, ZMIForm, ZopePageTemplate):
addMessage( addMessage(
'erp5-Guideline.Use.Correct.Names.For.Simulation.And.Validation.Titles', 'erp5-Guideline.Use.Correct.Names.For.Simulation.And.Validation.Titles',
'Workflow state fields should be named my_translated_${state_variable}_title') 'Workflow state fields should be named my_translated_${state_variable}_title')
# check fields, if they implement _checkConsistency
for field in self.objectValues():
_checkConsitency = getattr(field, '_checkConsistency', None)
if _checkConsitency is not None:
message_list.extend(_checkConsitency(fixit=fixit))
return message_list return message_list
......
...@@ -35,6 +35,7 @@ from Products.Formulator.Errors import ValidationError ...@@ -35,6 +35,7 @@ from Products.Formulator.Errors import ValidationError
from Products.Formulator import MethodField from Products.Formulator import MethodField
from Products.ERP5Type.Utils import convertToUpperCase from Products.ERP5Type.Utils import convertToUpperCase
from Products.ERP5Type.TransactionalVariable import getTransactionalVariable from Products.ERP5Type.TransactionalVariable import getTransactionalVariable
from Products.ERP5Type.ObjectMessage import ObjectMessage
from Products.PageTemplates.PageTemplateFile import PageTemplateFile from Products.PageTemplates.PageTemplateFile import PageTemplateFile
...@@ -790,6 +791,19 @@ class ProxyField(ZMIField): ...@@ -790,6 +791,19 @@ class ProxyField(ZMIField):
return cache.__of__(parent) return cache.__of__(parent)
raise KeyError raise KeyError
def _checkConsistency(self, fixit=False):
"""Check the proxy field internal data structures are consistent
"""
object_relative_url = '/'.join(self.getPhysicalPath())[len(self.getPortalObject().getPath()):]
difference = set(self.tales).difference(self.values)
assert not fixit, "todo"
if difference:
return [
ObjectMessage(
object_relative_url=object_relative_url,
message="Internal proxy field data structures are inconsistent. "
"Differences: {}".format(difference))]
return []
# #
# get_value exception dict # get_value exception dict
......
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