nicer mainvars/expression handling when initializing rql constraints stable
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Wed, 02 Dec 2009 12:52:55 +0100
branchstable
changeset 3963 0d592677e55f
parent 3962 15d9d47f5434
child 3964 21387ffb0731
nicer mainvars/expression handling when initializing rql constraints
schema.py
--- a/schema.py	Wed Dec 02 11:57:38 2009 +0100
+++ b/schema.py	Wed Dec 02 12:52:55 2009 +0100
@@ -559,11 +559,19 @@
     """
 
     def __init__(self, restriction, mainvars=None):
-        self.restriction = restriction
+        self.restriction = normalize_expression(restriction)
         if mainvars is None:
             mainvars = guess_rrqlexpr_mainvars(restriction)
+        else:
+            normmainvars = []
+            for mainvar in mainvars.split(','):
+                mainvar = mainvar.strip()
+                if not mainvar.isalpha():
+                    raise Exception('bad mainvars %s' % mainvars)
+                normmainvars.append(mainvar)
+            assert mainvars, 'bad mainvars %s' % mainvars
+            mainvars = ','.join(sorted(normmainvars))
         self.mainvars = mainvars
-        assert not ';' in mainvars # XXX check mainvars as for RQLExpression?
 
     def serialize(self):
         # start with a comma for bw compat, see below