Ticket #2430 (closed defect: fixed)
Widgets should use lazy params initialization to prevent from inconsistence
|Reported by:||xaka||Owned by:||chrisz|
Description (last modified by Chris Arndt) (diff)
Currently, when you pass params to a widget's constructor, the logic first looks at **params and then, if nothing was found, checks the self object.
All params are stored as ParamDescriptor instances on the meta-level and when the constructor checks the self object for param existence it calls __get__ of the descriptor, which do getattr(self, param) and call the returned value if it is callable.
Where is the problem?
class MyWidget(turbogears.widgets.Widget): @property def some_param(self): # connect to database, retrieve remote resource # or do another operation which can't be processed # at __init__ call-time ...
- ParamDescriptor should return None if param is undefined in object.
- The Widget constructor should not check self for param.
I've attach patch which fix that logic in right way (IMHO).
- Owner changed from Chris Arndt to chrisz
- Milestone changed from 1.0.x bugfix to 1.1.x bugfix