Hi folks,
I've tried passing a function as argument to @error_handler but it
doesn't seem to work. Is it possible at all? Or the argument has to be
a method? This is what I tried:
def error( dummy, tg_errors=None ):
return dict( errors=tg_errors, success=False, msg='There was an error' )
class controller( turbogears.controllers.Controller ):
@expose( )
@error_handler( error )
@validate( validators=dict( value=Int( ) ) )
def hello( self, value=2 ):
return dict( value=value )
The first argument, 'dummy', of error( ) serves as the placeholder for
the instance that is normally passed as first argument to a method.
The reason I go this way is that I'd like to have the same
error_handler for all methods of several controllers and want to
define this error_handler only once. If I define it as a method on one
of the controllers I can't really pass it to @error_handler decorating
another method in another controller, can I?
It might easily be that I'm overcomplicating something in which case
I'd be curious to know how you guys would deal with this situation.
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
-~----------~----~----~----~------~----~------~--~---