Igor Murashkin wrote:
> So what's the rationale behind not having per-request widgets?
Basically not having per-request widgets fits well with the TG and CP
philosophy, requires less code and once you grasp it makes more sense.
For example you use and validate a form in this way:
contact_form = TableForm(...)
@expose(...)
def show_form(...)
return dict(form=form)
@validate(form=contact_form)
@error_handler(show_form)
def save_form(...)
...
this is pretty straightforward.
If we had per-request widgets the above would be something like:
@expose(...)
def show_form(...)
contact_form = TableForm(...)
return dict(form=form)
@validate(form=TableForm(...))
@error_handler(show_form)
def save_form(...)
...
basically you need to provide a fair amount of code to be sure that the
widget instance you're passing to the validate decorator is exactly the
same (or better behaves the same) as the one used to submit the form.
There is also a (most probably) very small performance gain that you
have if you're reusing the same instance, also the web (the underlying
HTTP protocol) is intrinsically stateless and being stateless allows
you to easily share the same objects between processes and this helps
you to scale.
Note that the latter is not our main motivation anyway.
Ciao
Michele
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---