appobject.py
changeset 3390 ae50bd4b1631
parent 2968 0e3460341023
child 3396 fb261afd49cd
equal deleted inserted replaced
3389:59c0e6b34dd1 3390:ae50bd4b1631
     9 """
     9 """
    10 __docformat__ = "restructuredtext en"
    10 __docformat__ = "restructuredtext en"
    11 
    11 
    12 import types
    12 import types
    13 from logging import getLogger
    13 from logging import getLogger
       
    14 from warnings import warn
    14 
    15 
    15 from logilab.common.decorators import classproperty
    16 from logilab.common.decorators import classproperty
    16 from logilab.common.deprecation import deprecated
    17 from logilab.common.deprecation import deprecated
    17 from logilab.common.logging_ext import set_log_methods
    18 from logilab.common.logging_ext import set_log_methods
    18 
    19 
   248 
   249 
   249         It must return the object that will be actually registered (this may be
   250         It must return the object that will be actually registered (this may be
   250         the right hook to create an instance for example). By default the
   251         the right hook to create an instance for example). By default the
   251         appobject is returned without any transformation.
   252         appobject is returned without any transformation.
   252         """
   253         """
   253         pdefs = getattr(cls, 'cw_property_defs', {})
   254         try:
       
   255             pdefs = cls.property_defs
       
   256         except AttributeError:
       
   257             pdefs = getattr(cls, 'cw_property_defs', {})
       
   258         else:
       
   259             warn('property_defs is deprecated, use cw_property_defs in %s'
       
   260                  % cls, DeprecationWarning)
   254         for propid, pdef in pdefs.items():
   261         for propid, pdef in pdefs.items():
   255             pdef = pdef.copy() # may be shared
   262             pdef = pdef.copy() # may be shared
   256             pdef['default'] = getattr(cls, propid, pdef['default'])
   263             pdef['default'] = getattr(cls, propid, pdef['default'])
   257             pdef['sitewide'] = getattr(cls, 'site_wide', pdef.get('sitewide'))
   264             pdef['sitewide'] = getattr(cls, 'site_wide', pdef.get('sitewide'))
   258             registry.vreg.register_property(cls._cwpropkey(propid), **pdef)
   265             registry.vreg.register_property(cls._cwpropkey(propid), **pdef)