It shouldn't be too difficult to write a custom decorator to do make
it easier.  Something along the lines of:
def expose_and_validate(function)
    function = expose('template')(function)
    function = validate(whatever)(function)
    return function

For a little more of a challenge, I don't think it would be too hard
to include in your Controller's __init__ to loop through the methods
and do
setattr(self, name, expose_and_validate(getattr(self, name))

You could even add this to your BaseController

Personally, I would prefer that it would be explicit how and why a
particular method is exposed/validated by default.

On Dec 12, 4:00 pm, "Daniel Fetchinson" <[EMAIL PROTECTED]>
wrote:
> Hi list,
>
> I often find myself writing controller classes methods of which have
> the same expose and paginate decorator. Is there a way to declare
> these for the class as a whole and so then I don't have to add these
> to each and every method?
>
> A related question is whether if it was possible to validate
> positional arguments as opposed to keyword arguments? It seems to me
> the @validate( validators=dict( .... ) ) format only works for keyword
> arguments.
>
> Cheers,
> Daniel
--~--~---------~--~----~------------~-------~--~----~
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?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to