cubicweb/cwvreg.py
changeset 12540 623e9dd2977f
parent 11900 8496135b6dc1
child 12541 bbbccb0b3a66
equal deleted inserted replaced
12539:10159a3d1d72 12540:623e9dd2977f
    19 Cubicweb registries
    19 Cubicweb registries
    20 """
    20 """
    21 
    21 
    22 import sys
    22 import sys
    23 from os.path import join, dirname, realpath
    23 from os.path import join, dirname, realpath
    24 from warnings import warn
       
    25 from datetime import datetime, date, time, timedelta
    24 from datetime import datetime, date, time, timedelta
    26 from functools import reduce
    25 from functools import reduce
    27 
    26 
    28 from six import text_type, binary_type
    27 from six import text_type, binary_type
    29 
    28 
   293         for component in thisctxcomps:
   292         for component in thisctxcomps:
   294             component.cw_extra_kwargs['context'] = context
   293             component.cw_extra_kwargs['context'] = context
   295         return thisctxcomps
   294         return thisctxcomps
   296 
   295 
   297 
   296 
   298 class BwCompatCWRegistry(object):
       
   299     def __init__(self, vreg, oldreg, redirecttoreg):
       
   300         self.vreg = vreg
       
   301         self.oldreg = oldreg
       
   302         self.redirecto = redirecttoreg
       
   303 
       
   304     def __getattr__(self, attr):
       
   305         warn('[3.10] you should now use the %s registry instead of the %s registry'
       
   306              % (self.redirecto, self.oldreg), DeprecationWarning, stacklevel=2)
       
   307         return getattr(self.vreg[self.redirecto], attr)
       
   308 
       
   309     def clear(self): pass
       
   310     def initialization_completed(self): pass
       
   311 
       
   312 
       
   313 class CWRegistryStore(RegistryStore):
   297 class CWRegistryStore(RegistryStore):
   314     """Central registry for the cubicweb instance, extending the generic
   298     """Central registry for the cubicweb instance, extending the generic
   315     RegistryStore with some cubicweb specific stuff.
   299     RegistryStore with some cubicweb specific stuff.
   316 
   300 
   317     This is one of the central object in cubicweb instance, coupling
   301     This is one of the central object in cubicweb instance, coupling
   364                 sys.path.remove(webdir)
   348                 sys.path.remove(webdir)
   365         if CW_SOFTWARE_ROOT in sys.path:
   349         if CW_SOFTWARE_ROOT in sys.path:
   366             sys.path.remove(CW_SOFTWARE_ROOT)
   350             sys.path.remove(CW_SOFTWARE_ROOT)
   367         self.schema = None
   351         self.schema = None
   368         self.initialized = False
   352         self.initialized = False
   369         self['boxes'] = BwCompatCWRegistry(self, 'boxes', 'ctxcomponents')
       
   370         self['contentnavigation'] = BwCompatCWRegistry(self, 'contentnavigation', 'ctxcomponents')
       
   371 
   353 
   372     def setdefault(self, regid):
   354     def setdefault(self, regid):
   373         try:
   355         try:
   374             return self[regid]
   356             return self[regid]
   375         except RegistryNotFound:
   357         except RegistryNotFound: