> Or you can factor the common "do something with good values" part into an
> unexposed method and split your exposed method in various
> differently-decorated exposed methods, one for each form...
Nope...I tried this already:
@expose(template='templates.save')
@validate(form='ThisTypeForm')
def saveThisTypeOfElement:
return saveElement('ThisType')
def saveElement(type):
# do the work, return the dict formerly returned by exposed
methods
It works when there are no errors, but if there are validation errors,
the exceptions appear in the log, but are not propagated back to the
app. It appears that the unexposed method would still need to be
decorated, which leaves me in the same position as before. Or maybe I
need to assign the results of the factored-out method to local
variables in the exposed method? If so, it seems like a little too
much magic is going on.
It feels like @validate, widgets.WidgetsDeclaration and their ilk
encourage an architectural antipattern, which is that objects (forms,
widgets) are instantiated at compile (i.e., import) time, instead of
when the application first needs them. I've managed to avoid this to
some extent by using callables, but I see no way out in this case, save
to eschew TurboGears idioms.
I'd be interested in hearing what others think about this.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---