schema.py
branchstable
changeset 3963 0d592677e55f
parent 3961 d1cbf77db999
child 3964 21387ffb0731
equal deleted inserted replaced
3962:15d9d47f5434 3963:0d592677e55f
   557      `'Any %s WHERE ...' % mainvars`). If not specified, an attempt will be
   557      `'Any %s WHERE ...' % mainvars`). If not specified, an attempt will be
   558      done to guess it according to variable used in the expression.
   558      done to guess it according to variable used in the expression.
   559     """
   559     """
   560 
   560 
   561     def __init__(self, restriction, mainvars=None):
   561     def __init__(self, restriction, mainvars=None):
   562         self.restriction = restriction
   562         self.restriction = normalize_expression(restriction)
   563         if mainvars is None:
   563         if mainvars is None:
   564             mainvars = guess_rrqlexpr_mainvars(restriction)
   564             mainvars = guess_rrqlexpr_mainvars(restriction)
       
   565         else:
       
   566             normmainvars = []
       
   567             for mainvar in mainvars.split(','):
       
   568                 mainvar = mainvar.strip()
       
   569                 if not mainvar.isalpha():
       
   570                     raise Exception('bad mainvars %s' % mainvars)
       
   571                 normmainvars.append(mainvar)
       
   572             assert mainvars, 'bad mainvars %s' % mainvars
       
   573             mainvars = ','.join(sorted(normmainvars))
   565         self.mainvars = mainvars
   574         self.mainvars = mainvars
   566         assert not ';' in mainvars # XXX check mainvars as for RQLExpression?
       
   567 
   575 
   568     def serialize(self):
   576     def serialize(self):
   569         # start with a comma for bw compat, see below
   577         # start with a comma for bw compat, see below
   570         return ';' + self.mainvars + ';' + self.restriction
   578         return ';' + self.mainvars + ';' + self.restriction
   571 
   579