On Aug 18, 2006, at 2:16 PM, Damjan wrote:
>
>
>> For me, 1) alone makes widgets worth using. It's foolishly easy to
>> just:
>>
>> import tinymce
>> ....
>> def controller_method(...)
>> return dict(widget=TurboTinyMCE())
>>
>
> Aren't widgets supposed to be instantiated only once, and not for each
> request?
Yes and No ;)
Forms (not necessarily all widgets) should be instantiated just once
so it's the same instance both to the method that displays it and the
method that validates it:
form = Form()
class Controller:
@expose(...)
def show_form(...):
return(form=form)
@validate(form=form)
@error_handler(show_form)
@expose(...)
def save_data(...)
# process data
For other cases, like a DataGrid (or a lonely TinyMCE ;) )you can do
it per-request or just once. It's perfectly safe to reuse a (properly
written) widget in various requests as they should be stateless
(therefore thread-safe).
Alberto
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"TurboGears" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/turbogears
-~----------~----~----~----~------~----~------~--~---