Em Quarta 14 Junho 2006 11:22, Javier Rojas escreveu:
>
> is it OK to modify a form (a widget) at "runtime"?. For example, I
> want to use a form and add to it different fields depending on the
> controller function called
Then you're willing to have different widgets. This is OK, just declare then
in your method and use them.
> does the forms (widgets) have to be globals in the module? I'v tried
Nope, but if you want to use them as validators you have to remember how
scoping works and how decorators works.
> to use forms that are object attributes (self.form) or class
> attributes (Class.form), and the widget get rendered OK, but when I
> use it as a validator python complains about not being able to find
> the widget
@expose(...)
@error_handler(...)
@validate(...)
def function(...):
pass
is something like
def function(...):
pass
function = expose(error_handler(validate(function)))
so, if you had local variables inside your function, they won't be available
out of it. As you can see, decorators wraps functions, so ...
The easiest thing is to declare a global validator scheme -- of the widgets
themselves -- in your module and use them. You might try other things, but
always keep in mind what is happening behind the 'magic'.
--
Jorge Godoy <[EMAIL PROTECTED]>
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---