schema.py
changeset 2735 39c942241b48
parent 2730 bb6fcb8c5d71
child 2736 c5048502409f
equal deleted inserted replaced
2734:3f183182d581 2735:39c942241b48
   848 
   848 
   849     def load(self, config, path=(), **kwargs):
   849     def load(self, config, path=(), **kwargs):
   850         """return a Schema instance from the schema definition read
   850         """return a Schema instance from the schema definition read
   851         from <directory>
   851         from <directory>
   852         """
   852         """
   853         self.lib_directory = join(cubicweb.CW_SOFTWARE_ROOT, 'schemas')
       
   854         return super(BootstrapSchemaLoader, self).load(
   853         return super(BootstrapSchemaLoader, self).load(
   855             path, config.appid, register_base_types=False, **kwargs)
   854             path, config.appid, register_base_types=False, **kwargs)
   856 
   855 
   857     def _load_definition_files(self, cubes=None):
   856     def _load_definition_files(self, cubes=None):
   858         # bootstraping, ignore cubes
   857         # bootstraping, ignore cubes
   859         filepath = join(self.lib_directory, 'bootstrap.py')
   858         filepath = join(cubicweb.CW_SOFTWARE_ROOT, 'schemas', 'bootstrap.py')
   860         self.info('loading %s', filepath)
   859         self.info('loading %s', filepath)
   861         self.handle_file(filepath)
   860         self.handle_file(filepath)
   862 
   861 
   863     def unhandled_file(self, filepath):
   862     def unhandled_file(self, filepath):
   864         """called when a file without handler associated has been found"""
   863         """called when a file without handler associated has been found"""
   881             path = tuple(reversed(config.cubes_path()))
   880             path = tuple(reversed(config.cubes_path()))
   882         try:
   881         try:
   883             return super(CubicWebSchemaLoader, self).load(config, path=path, **kwargs)
   882             return super(CubicWebSchemaLoader, self).load(config, path=path, **kwargs)
   884         finally:
   883         finally:
   885             # we've to cleanup modules imported from cubicweb.schemas as well
   884             # we've to cleanup modules imported from cubicweb.schemas as well
   886             cleanup_sys_modules([self.lib_directory])
   885             cleanup_sys_modules([join(cubicweb.CW_SOFTWARE_ROOT, 'schemas')])
   887 
   886 
   888     def _load_definition_files(self, cubes):
   887     def _load_definition_files(self, cubes):
   889         for filepath in (join(self.lib_directory, 'bootstrap.py'),
   888         for filepath in (join(CW_SOFTWARE_ROOT, 'schemas', 'bootstrap.py'),
   890                          join(self.lib_directory, 'base.py'),
   889                          join(CW_SOFTWARE_ROOT, 'schemas', 'base.py'),
   891                          join(self.lib_directory, 'workflow.py'),
   890                          join(CW_SOFTWARE_ROOT, 'schemas', 'workflow.py'),
   892                          join(self.lib_directory, 'Bookmark.py')):
   891                          join(CW_SOFTWARE_ROOT, 'schemas', 'Bookmark.py')):
   893             self.info('loading %s', filepath)
   892             self.info('loading %s', filepath)
   894             self.handle_file(filepath)
   893             self.handle_file(filepath)
   895         for cube in cubes:
   894         for cube in cubes:
   896             for filepath in self.get_schema_files(cube):
   895             for filepath in self.get_schema_files(cube):
   897                 self.info('loading %s', filepath)
   896                 self.info('loading %s', filepath)