make groupmap argument optional / sort for testing purpose
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Tue, 22 Dec 2009 19:26:59 +0100
changeset 4189 bd552b341334
parent 4188 b3258d2afe04
child 4190 742e3eb16f81
make groupmap argument optional / sort for testing purpose
server/schemaserial.py
--- a/server/schemaserial.py	Tue Dec 22 19:26:12 2009 +0100
+++ b/server/schemaserial.py	Tue Dec 22 19:26:59 2009 +0100
@@ -400,7 +400,7 @@
     if subjtype is None:
         assert objtype is None
         assert props is None
-        targets = rschema.rdefs
+        targets = sorted(rschema.rdefs)
     else:
         assert not objtype is None
         targets = [(subjtype, objtype)]
@@ -449,7 +449,7 @@
         return eschema2rql(erschema, groupmap=groupmap)
     return rschema2rql(erschema, groupmap=groupmap)
 
-def eschema2rql(eschema, groupmap):
+def eschema2rql(eschema, groupmap=None):
     """return a list of rql insert statements to enter an entity schema
     in the database as an CWEType entity
     """
@@ -457,10 +457,11 @@
     # NOTE: 'specializes' relation can't be inserted here since there's no
     # way to make sure the parent type is inserted before the child type
     yield 'INSERT CWEType X: %s' % ','.join(relations) , values
-        # entity schema
-    for rql, args in _erperms2rql(eschema, groupmap):
-        args['name'] = str(eschema)
-        yield rql + 'X is CWEType, X name %(name)s', args
+    # entity permissions
+    if groupmap is not None:
+        for rql, args in _erperms2rql(eschema, groupmap):
+            args['name'] = str(eschema)
+            yield rql + 'X is CWEType, X name %(name)s', args
 
 def specialize2rql(schema):
     for eschema in schema.entities():