Commit 367357b7 authored by Arnaud Fontaine's avatar Arnaud Fontaine

Check whether the source code is valid upon validate().

parent 5d48a7a6
......@@ -32,6 +32,7 @@ from AccessControl import ClassSecurityInfo
from Products.ERP5Type import Permissions
from Products.ERP5Type.Base import Base
from Products.ERP5Type.Accessor.Constant import PropertyGetter as ConstantGetter
from Products.ERP5Type.ConsistencyMessage import ConsistencyMessage
class DocumentComponent(Base):
# CMF Type Definition
......@@ -55,6 +56,26 @@ class DocumentComponent(Base):
'Reference',
'TextDocument')
def checkConsistency(self, **kw):
"""
XXX-arnau: should probably in a separate Constraint class
"""
if not self.getTextContent():
return [ConsistencyMessage(self,
object_relative_url=self.getRelativeUrl(),
message="No source code",
mapping={})]
try:
self.load()
except Exception, e:
return [ConsistencyMessage(self,
object_relative_url=self.getRelativeUrl(),
message="Source code error: %s" % e,
mapping={})]
return []
def load(self, namespace_dict={}):
"""
Load the source code into the given dict. Using exec() rather than
......
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