コード例 #1
0
    def application(cls, f):
        """Decorate a function as responder that accepts the request as
        first argument.  This works like the `responder` decorator but
        the function is passed the request object as first argument::

            @Request.application
            def my_wsgi_app(request):
                return Response('Hello World!')
        """
        return _patch_wrapper(f, lambda *a: f(cls(a[-2]))(*a[-2:]))
コード例 #2
0
ファイル: wsgi.py プロジェクト: s0undt3ch/werkzeug
def responder(f):
    """Marks a function as responder.  Decorate a function with it and it
    will automatically call the return value as WSGI application.

    Example::

        @responder
        def application(environ, start_response):
            return Response('Hello World!')
    """
    return _patch_wrapper(f, lambda *a: f(*a)(*a[-2:]))
コード例 #3
0
ファイル: wsgi.py プロジェクト: tom2jack/pj-redis
def responder(f):
    """Marks a function as responder.  Decorate a function with it and it
    will automatically call the return value as WSGI application.

    Example::

        @responder
        def application(environ, start_response):
            return Response('Hello World!')
    """
    return _patch_wrapper(f, lambda *a: f(*a)(*a[-2:]))
コード例 #4
0
ファイル: local.py プロジェクト: good1111/pj-redis
    def middleware(self, func):
        """Like `make_middleware` but for decorating functions.

        Example usage::

            @manager.middleware
            def application(environ, start_response):
                ...

        The difference to `make_middleware` is that the function passed
        will have all the arguments copied from the inner application
        (name, docstring, module).
        """
        return _patch_wrapper(func, self.make_middleware(func))
コード例 #5
0
    def middleware(self, func):
        """Like `make_middleware` but for decorating functions.

        Example usage::

            @manager.middleware
            def application(environ, start_response):
                ...

        The difference to `make_middleware` is that the function passed
        will have all the arguments copied from the inner application
        (name, docstring, module).
        """
        return _patch_wrapper(func, self.make_middleware(func))
コード例 #6
0
ファイル: wrappers.py プロジェクト: SRabbelier/Casam
    def application(cls, f):
        """Decorate a function as responder that accepts the request as
        first argument.  This works like the `responder` decorator but
        the function is passed the request object as first argument::

            @Request.application
            def my_wsgi_app(request):
                return Response('Hello World!')
        """
        #: return a callable that wraps the -2nd argument with the request
        #: and calls the function with all the arguments up to that one and
        #: the request.  The return value is then called with the latest
        #: two arguments.  This makes it possible to use this decorator for
        #: both methods and standalone WSGI functions.
        return _patch_wrapper(f, lambda *a: f(*a[:-2]+(cls(a[-2]),))(*a[-2:]))
コード例 #7
0
 def middleware(self, func):
     return _patch_wrapper(func, self.make_middleware(func))
コード例 #8
0
ファイル: wsgi.py プロジェクト: connoryang/dec-eve-serenity
def responder(f):
    return _patch_wrapper(f, lambda *a: f(*a)(*a[-2:]))
コード例 #9
0
 def application(cls, f):
     return _patch_wrapper(f, lambda *a: f(*(a[:-2] + (cls(a[-2]),)))(*a[-2:]))
コード例 #10
0
ファイル: local.py プロジェクト: connoryang/dec-eve-serenity
 def middleware(self, func):
     return _patch_wrapper(func, self.make_middleware(func))
コード例 #11
0
def responder(f):
    return _patch_wrapper(f, lambda *a: f(*a)(*a[-2:]))
コード例 #12
0
 def application(cls, f):
     return _patch_wrapper(f, lambda *a: f(*(a[:-2] + (cls(a[-2]),)))(*a[-2:]))