204 |
204 |
205 def __init__(self, config): |
205 def __init__(self, config): |
206 super(VRegistry, self).__init__() |
206 super(VRegistry, self).__init__() |
207 self.config = config |
207 self.config = config |
208 |
208 |
209 def reset(self, force_reload=None): |
209 def reset(self, path=None, force_reload=None): |
210 self.clear() |
210 self.clear() |
211 self._lastmodifs = {} |
211 self._lastmodifs = {} |
212 |
212 |
213 def __getitem__(self, name): |
213 def __getitem__(self, name): |
214 """return the registry (dictionary of class objects) associated to |
214 """return the registry (dictionary of class objects) associated to |
316 # to avoid loading same module twice, especially with the |
316 # to avoid loading same module twice, especially with the |
317 # _load_ancestors_then_object logic but this needs to be checked |
317 # _load_ancestors_then_object logic but this needs to be checked |
318 self._loadedmods = {} |
318 self._loadedmods = {} |
319 return filemods |
319 return filemods |
320 |
320 |
321 def register_objects(self, path, force_reload=None, extrapath=None): |
321 def register_objects(self, path, force_reload, extrapath=None): |
322 if force_reload is None: |
|
323 force_reload = self.config.mode == 'dev' |
|
324 elif not force_reload: |
|
325 # force_reload == False usually mean modules have been reloaded |
|
326 # by another connection, so we want to update the registry |
|
327 # content even if there has been no module content modification |
|
328 self.reset() |
|
329 # need to clean sys.path this to avoid import confusion pb (i.e. |
322 # need to clean sys.path this to avoid import confusion pb (i.e. |
330 # having the same module loaded as 'cubicweb.web.views' subpackage and |
323 # having the same module loaded as 'cubicweb.web.views' subpackage and |
331 # as views' or 'web.views' subpackage |
324 # as views' or 'web.views' subpackage |
332 # this is mainly for testing purpose, we should'nt need this in |
325 # this is mainly for testing purpose, we should'nt need this in |
333 # production environment |
326 # production environment |