from collections import defaultdict from werkzeug import Local, LocalManager from werkzeug.exceptions import HTTPException, InternalServerError, NotFound, _ProxyException # fragment taken from timeit module if sys.platform == "win32": # On Windows, the best timer is time.clock() timer = time.clock else: # On most other platforms the best timer is time.time() timer = time.time local = Local() local_manager = LocalManager([local]) logging.basicConfig(stream=local('error_stream')) local.error_stream = sys.stderr # prevent the werkzeug logger from propagating messages because it has its own output scheme #logging.getLogger('werkzeug').propagate = False from modulo.actions import all_of, any_of, opt from modulo.wrappers import Request, Response def run_everything(tree, request): t0 = timer() handler = tree.handle(request, defaultdict(dict)) # This is where the parameter list gets constructed if handler is None: raise NotFound() logging.getLogger('modulo.actions').debug('\n'+str(handler)) response = Response() request.handler = handler