def filter_err(status, application='app', ticket='tkt'):
 routes = THREAD_LOCAL.routes
 if ((status > 399) and routes.routes_onerror):
  keys = set((('%s/%s' % (application, status)), ('%s/*' % application), ('*/%s' % status), '*/*'))
  for (key, redir) in routes.routes_onerror:
   if (key in keys):
    if (redir == '!'):
     break
    elif ('?' in redir):
     url = ((redir + '&') + ('code=%s&ticket=%s' % (status, ticket)))
    else:
     url = ((redir + '?') + ('code=%s&ticket=%s' % (status, ticket)))
    return url
 return status

def filter_err ( status , application = 'app' , ticket = 'tkt' ) : routes = THREAD_LOCAL . routes if ( ( status > 399 ) and routes . routes_onerror ) : keys = set ( ( ( '%s/%s' % ( application , status ) ) , ( '%s/*' % application ) , ( '*/%s' % status ) , '*/*' ) ) for ( key , redir ) in routes . routes_onerror : if ( key in keys ) : if ( redir == '!' ) : break elif ( '?' in redir ) : url = ( ( redir + '&' ) + ( 'code=%s&ticket=%s' % ( status , ticket ) ) ) else : url = ( ( redir + '?' ) + ( 'code=%s&ticket=%s' % ( status , ticket ) ) ) return url return status
doctest/unittest interface to routes_onerror .