Warning: Can't synchronize with repository "(default)" (Unsupported version control system "svn": No module named svn). Look in the Trac log for more information.

Ticket #2430: lazy-param-initialization.patch

File lazy-param-initialization.patch, 2.2 KB (added by xaka, 2 years ago)
  • turbogears/widgets/base.py

    old new  
    187187            if param in params: 
    188188                # make sure we don't keep references to mutables 
    189189                setattr(self, param, copy_if_mutable(params.pop(param))) 
    190  
    191190            else: 
    192                 if hasattr(self, param): 
    193                     # make sure we don't alter mutable class attributes 
    194                     value = copy_if_mutable(getattr(self.__class__, param), 
    195                                             True) 
    196                     if value[1]: 
    197                         # re-set it only if mutable 
    198                         setattr(self, param, value[0]) 
    199                 else: 
    200                     setattr(self, param, None) 
     191                # make sure we don't alter mutable class attributes 
     192                value = copy_if_mutable(getattr(self.__class__, param), True) 
     193                if value[1]: 
     194                    # re-set it only if mutable 
     195                    setattr(self, param, value[0]) 
    201196 
    202197        for unused in params.iterkeys(): 
    203198            warnings.warn('keyword argument "%s" is unused at %r instance' % ( 
  • turbogears/widgets/meta.py

    old new  
    5959                dct[param] = ParamDescriptor(param) 
    6060            except KeyError: 
    6161                # declared in a superclass, skip it... 
    62                 pass 
     62                if [base for base in bases if hasattr(base, param)]: 
     63                    continue 
     64 
     65                # not declared anywhere and because set it 
     66                # by default to None 
     67                dct[param_prefix+param] = None 
     68                dct[param] = ParamDescriptor(param) 
    6369        params = list(params) 
    6470        dct['params'] = params 
    6571        #XXX: Remove when deprecation is effective