schema.py
changeset 7383 1719eab69551
parent 7152 39c1ffc7d93f
child 7440 539de926ec9d
--- 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