schema.py
changeset 7109 611663348158
parent 7103 9acffa1ecb2f
child 7152 39c1ffc7d93f
equal deleted inserted replaced
7077:784d6f300070 7109:611663348158
   795     def match_condition(self, session, eidfrom, eidto):
   795     def match_condition(self, session, eidfrom, eidto):
   796         return len(self.exec_query(session, eidfrom, eidto)) <= 1
   796         return len(self.exec_query(session, eidfrom, eidto)) <= 1
   797 
   797 
   798 
   798 
   799 class RQLExpression(object):
   799 class RQLExpression(object):
       
   800 
   800     def __init__(self, expression, mainvars, eid):
   801     def __init__(self, expression, mainvars, eid):
   801         self.eid = eid # eid of the entity representing this rql expression
   802         self.eid = eid # eid of the entity representing this rql expression
   802         if not isinstance(mainvars, unicode):
   803         if not isinstance(mainvars, unicode):
   803             mainvars = unicode(mainvars)
   804             mainvars = unicode(mainvars)
   804         self.mainvars = mainvars
   805         self.mainvars = mainvars
   941 
   942 
   942     @property
   943     @property
   943     def minimal_rql(self):
   944     def minimal_rql(self):
   944         return 'Any %s WHERE %s' % (self.mainvars, self.expression)
   945         return 'Any %s WHERE %s' % (self.mainvars, self.expression)
   945 
   946 
       
   947     # these are overridden by set_log_methods below
       
   948     # only defining here to prevent pylint from complaining
       
   949     info = warning = error = critical = exception = debug = lambda msg,*a,**kw: None
       
   950 
   946 
   951 
   947 class ERQLExpression(RQLExpression):
   952 class ERQLExpression(RQLExpression):
   948     def __init__(self, expression, mainvars=None, eid=None):
   953     def __init__(self, expression, mainvars=None, eid=None):
   949         RQLExpression.__init__(self, expression, mainvars or 'X', eid)
   954         RQLExpression.__init__(self, expression, mainvars or 'X', eid)
   950 
   955 
  1101 
  1106 
  1102     def unhandled_file(self, filepath):
  1107     def unhandled_file(self, filepath):
  1103         """called when a file without handler associated has been found"""
  1108         """called when a file without handler associated has been found"""
  1104         self.warning('ignoring file %r', filepath)
  1109         self.warning('ignoring file %r', filepath)
  1105 
  1110 
       
  1111     # these are overridden by set_log_methods below
       
  1112     # only defining here to prevent pylint from complaining
       
  1113     info = warning = error = critical = exception = debug = lambda msg,*a,**kw: None
  1106 
  1114 
  1107 class CubicWebSchemaLoader(BootstrapSchemaLoader):
  1115 class CubicWebSchemaLoader(BootstrapSchemaLoader):
  1108     """cubicweb specific schema loader, automatically adding metadata to the
  1116     """cubicweb specific schema loader, automatically adding metadata to the
  1109     instance's schema
  1117     instance's schema
  1110     """
  1118     """
  1138         for cube in cubes:
  1146         for cube in cubes:
  1139             for filepath in self.get_schema_files(cube):
  1147             for filepath in self.get_schema_files(cube):
  1140                 self.info('loading %s', filepath)
  1148                 self.info('loading %s', filepath)
  1141                 self.handle_file(filepath)
  1149                 self.handle_file(filepath)
  1142 
  1150 
       
  1151     # these are overridden by set_log_methods below
       
  1152     # only defining here to prevent pylint from complaining
       
  1153     info = warning = error = critical = exception = debug = lambda msg,*a,**kw: None
  1143 
  1154 
  1144 set_log_methods(CubicWebSchemaLoader, getLogger('cubicweb.schemaloader'))
  1155 set_log_methods(CubicWebSchemaLoader, getLogger('cubicweb.schemaloader'))
  1145 set_log_methods(BootstrapSchemaLoader, getLogger('cubicweb.bootstrapschemaloader'))
  1156 set_log_methods(BootstrapSchemaLoader, getLogger('cubicweb.bootstrapschemaloader'))
  1146 set_log_methods(RQLExpression, getLogger('cubicweb.schema'))
  1157 set_log_methods(RQLExpression, getLogger('cubicweb.schema'))
  1147 
  1158