#2430: Widgets should use lazy params initialization to prevent from
inconsistence
------------------------+---------------------------------------------------
Reporter: xaka | Owner: Chris Arndt
Type: defect | Status: new
Priority: normal | Milestone: 1.0.x bugfix
Component: TG Widgets | Version: 1.0.9
Severity: normal | Resolution:
Keywords: |
------------------------+---------------------------------------------------
Comment (by xaka):
After long research i've found better solution for "my problem", also
there is another problem occured today: if param was not declared anywhere
in bases or self class it will set to None without wrapping it into
ParamDescriptor and if later we assign to param any callable object it
will not work as expected (i.e. call callable object and return result, as
ParamDescriptor work).
Latest version of patch set param to None and uses ParamDescriptor. All
this on meta-level.
At __init__ time i remove hasattr checking (because it not need after
above changes on meta-level) and leave copy mutables.
Must work with 100% backward-compatible and transparent to
users/programmers.
Test when no param declaration anywhere.
{{{
class MyWidget(turbogears.widgets.Widget):
params = ['call_me']
widget = MyWidget()
print widget.call_me # output "None", ok
def call_me():
return 'hello world'
widget.call_me = call_me # we can set it here or in constructor before
display
print widget.call_me # output "<function call_me ...>", wrong, we expect
"hello world"
}}}
--
Ticket URL: <http://trac.turbogears.org/ticket/2430#comment:1>
TurboGears <http://www.turbogears.org/>
TurboGears front-to-back web development
--
You received this message because you are subscribed to the Google
Groups "TurboGears Tickets" group.
This group is read-only. No posting by normal members allowed.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/turbogears-tickets?hl=en?hl=en