def process_token_or_pass(func):
 @functools.wraps(func)
 def wrapper(*args, **kwargs):
  encoded_token = request.args.get('token')
  if encoded_token:
   handler = TokenHandler.from_string(encoded_token)
   try:
    res = handler.to_response()
   except TokenHandlerNotFound as e:
    raise HTTPError(http.BAD_REQUEST, data={'message_short': 'Invalid Token', 'message_long': 'No token handler for action: {} found'.format(e.action)})
   if res:
    return res
  return func(*args, **kwargs)
 return wrapper

def process_token_or_pass ( func ) : @ functools . wraps ( func ) def wrapper ( * args , ** kwargs ) : encoded_token = request . args . get ( 'token' ) if encoded_token : handler = TokenHandler . from_string ( encoded_token ) try : res = handler . to_response ( ) except TokenHandlerNotFound as e : raise HTTPError ( http . BAD_REQUEST , data = { 'message_short' : 'Invalid Token' , 'message_long' : 'No token handler for action: {} found' . format ( e . action ) } ) if res : return res return func ( * args , ** kwargs ) return wrapper
parse encoded token and run attached handlers .