19 |
19 |
20 __docformat__ = "restructuredtext en" |
20 __docformat__ = "restructuredtext en" |
21 _ = unicode |
21 _ = unicode |
22 |
22 |
23 import re |
23 import re |
24 from os.path import join |
24 from os.path import join, basename |
25 from logging import getLogger |
25 from logging import getLogger |
26 from warnings import warn |
26 from warnings import warn |
27 |
27 |
|
28 from logilab.common import tempattr |
28 from logilab.common.decorators import cached, clear_cache, monkeypatch, cachedproperty |
29 from logilab.common.decorators import cached, clear_cache, monkeypatch, cachedproperty |
29 from logilab.common.logging_ext import set_log_methods |
30 from logilab.common.logging_ext import set_log_methods |
30 from logilab.common.deprecation import deprecated, class_moved, moved |
31 from logilab.common.deprecation import deprecated, class_moved, moved |
31 from logilab.common.textutils import splitstrip |
32 from logilab.common.textutils import splitstrip |
32 from logilab.common.graph import get_cycles |
33 from logilab.common.graph import get_cycles |
730 'expression %s', mainvar, self) |
731 'expression %s', mainvar, self) |
731 # syntax tree used by read security (inserted in queries when necessary) |
732 # syntax tree used by read security (inserted in queries when necessary) |
732 self.snippet_rqlst = parse(self.minimal_rql, print_errors=False).children[0] |
733 self.snippet_rqlst = parse(self.minimal_rql, print_errors=False).children[0] |
733 # graph of links between variables, used by rql rewriter |
734 # graph of links between variables, used by rql rewriter |
734 self.vargraph = vargraph(self.rqlst) |
735 self.vargraph = vargraph(self.rqlst) |
|
736 # useful for some instrumentation, e.g. localperms permcheck command |
|
737 self.package = ybo.PACKAGE |
735 |
738 |
736 def __str__(self): |
739 def __str__(self): |
737 return self.full_rql |
740 return self.full_rql |
738 def __repr__(self): |
741 def __repr__(self): |
739 return '%s(%s)' % (self.__class__.__name__, self.full_rql) |
742 return '%s(%s)' % (self.__class__.__name__, self.full_rql) |
1161 |
1164 |
1162 def _load_definition_files(self, cubes=None): |
1165 def _load_definition_files(self, cubes=None): |
1163 # bootstraping, ignore cubes |
1166 # bootstraping, ignore cubes |
1164 filepath = join(cubicweb.CW_SOFTWARE_ROOT, 'schemas', 'bootstrap.py') |
1167 filepath = join(cubicweb.CW_SOFTWARE_ROOT, 'schemas', 'bootstrap.py') |
1165 self.info('loading %s', filepath) |
1168 self.info('loading %s', filepath) |
1166 self.handle_file(filepath) |
1169 with tempattr(ybo, 'PACKAGE', 'cubicweb'): # though we don't care here |
|
1170 self.handle_file(filepath) |
1167 |
1171 |
1168 def unhandled_file(self, filepath): |
1172 def unhandled_file(self, filepath): |
1169 """called when a file without handler associated has been found""" |
1173 """called when a file without handler associated has been found""" |
1170 self.warning('ignoring file %r', filepath) |
1174 self.warning('ignoring file %r', filepath) |
1171 |
1175 |
1201 for filepath in (join(cubicweb.CW_SOFTWARE_ROOT, 'schemas', 'bootstrap.py'), |
1205 for filepath in (join(cubicweb.CW_SOFTWARE_ROOT, 'schemas', 'bootstrap.py'), |
1202 join(cubicweb.CW_SOFTWARE_ROOT, 'schemas', 'base.py'), |
1206 join(cubicweb.CW_SOFTWARE_ROOT, 'schemas', 'base.py'), |
1203 join(cubicweb.CW_SOFTWARE_ROOT, 'schemas', 'workflow.py'), |
1207 join(cubicweb.CW_SOFTWARE_ROOT, 'schemas', 'workflow.py'), |
1204 join(cubicweb.CW_SOFTWARE_ROOT, 'schemas', 'Bookmark.py')): |
1208 join(cubicweb.CW_SOFTWARE_ROOT, 'schemas', 'Bookmark.py')): |
1205 self.info('loading %s', filepath) |
1209 self.info('loading %s', filepath) |
1206 self.handle_file(filepath) |
1210 with tempattr(ybo, 'PACKAGE', 'cubicweb'): |
|
1211 self.handle_file(filepath) |
1207 for cube in cubes: |
1212 for cube in cubes: |
1208 for filepath in self.get_schema_files(cube): |
1213 for filepath in self.get_schema_files(cube): |
1209 self.info('loading %s', filepath) |
1214 with tempattr(ybo, 'PACKAGE', basename(cube)): |
1210 self.handle_file(filepath) |
1215 self.handle_file(filepath) |
1211 |
1216 |
1212 # these are overridden by set_log_methods below |
1217 # these are overridden by set_log_methods below |
1213 # only defining here to prevent pylint from complaining |
1218 # only defining here to prevent pylint from complaining |
1214 info = warning = error = critical = exception = debug = lambda msg,*a,**kw: None |
1219 info = warning = error = critical = exception = debug = lambda msg,*a,**kw: None |
1215 |
1220 |