vregistry.py
changeset 5752 b0bb553e3be4
parent 5696 98d390c28edb
parent 5748 487ab6ac90cc
child 6014 a5e22657f6f4
equal deleted inserted replaced
5743:4a0600664f85 5752:b0bb553e3be4
   402         #     to avoid loading same module twice, especially with the
   402         #     to avoid loading same module twice, especially with the
   403         #     _load_ancestors_then_object logic but this needs to be checked
   403         #     _load_ancestors_then_object logic but this needs to be checked
   404         self._loadedmods = {}
   404         self._loadedmods = {}
   405         return filemods
   405         return filemods
   406 
   406 
   407     def register_objects(self, path, force_reload=False, extrapath=None):
   407     def register_objects(self, path, extrapath=None):
   408         # load views from each directory in the instance's path
   408         # load views from each directory in the instance's path
   409         filemods = self.init_registration(path, extrapath)
   409         filemods = self.init_registration(path, extrapath)
   410         for filepath, modname in filemods:
   410         for filepath, modname in filemods:
   411             self.load_file(filepath, modname, force_reload)
   411             self.load_file(filepath, modname)
   412         self.initialization_completed()
   412         self.initialization_completed()
   413 
   413 
   414     def initialization_completed(self):
   414     def initialization_completed(self):
   415         for regname, reg in self.iteritems():
   415         for regname, reg in self.iteritems():
   416             reg.initialization_completed()
   416             reg.initialization_completed()
   444                 if fileordir not in lastmodifs or lastmodifs[fileordir] < mdate:
   444                 if fileordir not in lastmodifs or lastmodifs[fileordir] < mdate:
   445                     self.info('File %s changed since last visit', fileordir)
   445                     self.info('File %s changed since last visit', fileordir)
   446                     return True
   446                     return True
   447         return False
   447         return False
   448 
   448 
   449     def load_file(self, filepath, modname, force_reload=False):
   449     def load_file(self, filepath, modname):
   450         """load app objects from a python file"""
   450         """load app objects from a python file"""
   451         from logilab.common.modutils import load_module_from_name
   451         from logilab.common.modutils import load_module_from_name
   452         if modname in self._loadedmods:
   452         if modname in self._loadedmods:
   453             return
   453             return
   454         self._loadedmods[modname] = {}
   454         self._loadedmods[modname] = {}
   461         # set update time before module loading, else we get some reloading
   461         # set update time before module loading, else we get some reloading
   462         # weirdness in case of syntax error or other error while importing the
   462         # weirdness in case of syntax error or other error while importing the
   463         # module
   463         # module
   464         self._lastmodifs[filepath] = mdate
   464         self._lastmodifs[filepath] = mdate
   465         # load the module
   465         # load the module
   466         module = load_module_from_name(modname, use_sys=not force_reload)
   466         module = load_module_from_name(modname)
   467         self.load_module(module)
   467         self.load_module(module)
   468 
   468 
   469     def load_module(self, module):
   469     def load_module(self, module):
   470         self.info('loading %s', module)
   470         self.info('loading %s', module)
   471         if hasattr(module, 'registration_callback'):
   471         if hasattr(module, 'registration_callback'):