[schema] fix imprecise error message
authorAurelien Campeas <aurelien.campeas@logilab.fr>
Fri, 13 May 2011 18:47:03 +0200
changeset 7383 1719eab69551
parent 7382 91061a22755d
child 7385 29f050e39b09
[schema] fix imprecise error message
schema.py
--- a/schema.py	Fri May 13 14:58:16 2011 +0200
+++ b/schema.py	Fri May 13 18:47:03 2011 +0200
@@ -528,14 +528,15 @@
         rschema = self.add_relation_type(ybo.RelationType('identity'))
         rschema.final = False
 
+    etype_name_re = r'[A-Z][A-Za-z0-9]*[a-z]+[0-9]*$'
     def add_entity_type(self, edef):
         edef.name = edef.name.encode()
         edef.name = bw_normalize_etype(edef.name)
-        if not re.match(r'[A-Z][A-Za-z0-9]*[a-z]+[0-9]*$', edef.name):
+        if not re.match(self.etype_name_re, edef.name):
             raise BadSchemaDefinition(
-                '%r is not a valid name for an entity type. It should start '
-                'with an upper cased letter and be followed by at least a '
-                'lower cased letter' % edef.name)
+                '%r is not a valid name for an entity type. It should match '
+                'the following regular expresion: %r' % (edef.name,
+                                                         self.etype_name_re))
         eschema = super(CubicWebSchema, self).add_entity_type(edef)
         if not eschema.final:
             # automatically add the eid relation to non final entity types