def handle_class(cls): meth = http.request.method if meth == 'HEAD' and not hasattr(cls, meth): meth = 'GET' if not hasattr(cls, meth): raise http.nomethod(cls) tocall = getattr(cls(), meth) c = tocall.func_code.co_argcount if (c - len(args)) > 1: return tocall(http.request, *args) else: return tocall(*args)
def wsgi(env, start_resp): # clear threadlocal to avoid inteference of previous requests self._cleanup() self.load(env) try: # allow uppercase methods only if http.request.method.upper() != http.request.method: raise http.nomethod() result = self.handle_with_processors() if isinstance(result, tuple) and len(result)==2: content_type, result = result[0], [result[1]] http.header("Content-type", content_type, unique=True) elif is_generator(result): result = peep(result) else: result = [result] except http.HTTPError, e: result = [e.data]