[schema] add utility function to build a CubicWebSchema from a namespace
authorRémi Cardona <remi.cardona@logilab.fr>
Fri, 12 Sep 2014 14:10:03 +0200
changeset 9951 8cdcbf3f4fd0
parent 9950 3e5addc72575
child 9952 0f3f965b6365
[schema] add utility function to build a CubicWebSchema from a namespace Will be useful for testing computed attributes and relations.
__pkginfo__.py
cubicweb.spec
debian/control
schema.py
--- a/__pkginfo__.py	Thu Aug 28 18:12:28 2014 +0200
+++ b/__pkginfo__.py	Fri Sep 12 14:10:03 2014 +0200
@@ -42,7 +42,7 @@
     'logilab-common': '>= 0.60.0',
     'logilab-mtconverter': '>= 0.8.0',
     'rql': '>= 0.31.2',
-    'yams': '>= 0.39.1',
+    'yams': '>= 0.40.0',
     #gettext                    # for xgettext, msgcat, etc...
     # web dependencies
     'lxml': '',
--- a/cubicweb.spec	Thu Aug 28 18:12:28 2014 +0200
+++ b/cubicweb.spec	Fri Sep 12 14:10:03 2014 +0200
@@ -23,7 +23,7 @@
 Requires:       %{python}-logilab-common >= 0.60.0
 Requires:       %{python}-logilab-mtconverter >= 0.8.0
 Requires:       %{python}-rql >= 0.31.2
-Requires:       %{python}-yams >= 0.39.1
+Requires:       %{python}-yams >= 0.40.0
 Requires:       %{python}-logilab-database >= 1.12.1
 Requires:       %{python}-passlib
 Requires:       %{python}-lxml
--- a/debian/control	Thu Aug 28 18:12:28 2014 +0200
+++ b/debian/control	Fri Sep 12 14:10:03 2014 +0200
@@ -15,7 +15,7 @@
  python-unittest2 | python (>= 2.7),
  python-logilab-mtconverter,
  python-rql,
- python-yams (>= 0.39.1),
+ python-yams (>= 0.40.0),
  python-lxml,
 Standards-Version: 3.9.1
 Homepage: http://www.cubicweb.org
@@ -152,7 +152,7 @@
  gettext,
  python-logilab-mtconverter (>= 0.8.0),
  python-logilab-common (>= 0.60.0),
- python-yams (>= 0.39.1),
+ python-yams (>= 0.40.0),
  python-rql (>= 0.31.2),
  python-lxml
 Recommends:
--- a/schema.py	Thu Aug 28 18:12:28 2014 +0200
+++ b/schema.py	Fri Sep 12 14:10:03 2014 +0200
@@ -37,7 +37,8 @@
      RelationDefinitionSchema, PermissionMixIn, role_name
 from yams.constraints import BaseConstraint, FormatConstraint
 from yams.reader import (CONSTRAINTS, PyFileReader, SchemaLoader,
-                         obsolete as yobsolete, cleanup_sys_modules)
+                         obsolete as yobsolete, cleanup_sys_modules,
+                         fill_schema_from_namespace)
 
 from rql import parse, nodes, RQLSyntaxError, TypeResolverException
 
@@ -106,6 +107,11 @@
 ybo.ETYPE_PROPERTIES += ('eid',)
 ybo.RTYPE_PROPERTIES += ('eid',)
 
+def build_schema_from_namespace(items):
+    schema = CubicWebSchema('noname')
+    fill_schema_from_namespace(schema, items, register_base_types=False)
+    return schema
+
 # Bases for manipulating RQL in schema #########################################
 
 def guess_rrqlexpr_mainvars(expression):