def __call__(self, req, *args, **kw):
        func = self.func
        if func is None:
            if args or kw:
                raise TypeError(
                    "Unbound %s can only be called with the function it will wrap"
                    % self.__class__.__name__)
            func = req
            return self.clone(func)
        if isinstance(req, dict):
            if len(args) != 1 or kw:
                raise TypeError(
                    "Calling %r as a WSGI app with the wrong signature")
            environ = req
            start_response = args[0]
            req = self.RequestClass(environ)
            req.response = req.ResponseClass()
            req.response.request = req
            try:
                args = self.args
                if self.middleware_wraps:
                    args = (self.middleware_wraps,) + args
                resp = self.call_func(req, *args, **self.kwargs)
            except webob.exc.HTTPException, resp:
                pass
            if resp is None:
                ## FIXME: I'm not sure what this should be?
                resp = req.response
            elif isinstance(resp, basestring):
                body = resp
                resp = req.response
                resp.write(body)
            if resp is not req.response:
                resp = req.response.merge_cookies(resp)
            return resp(environ, start_response)
        else:
            if self.middleware_wraps:
                args = (self.middleware_wraps,) + args
            return self.func(req, *args, **kw)
Call this as a WSGI application or with a request
dataset/ETHPy150Open AppScale/appscale/AppServer/lib/webob-1.1.1/webob/dec.py/wsgify.__call__