addons14/base_rest/restapi.py
def method(
    routes, input_param=None, output_param=None, auth=None, cors=None, csrf=False
):
    """Decorator marking the decorated method as being a handler for
      REST requests. The method must be part of a component inheriting from
    ``base.rest.service``.

      :param routes: list of tuple (path, http method). path is a string or
                    array.
                    Each tuple determines which http requests and http method
                    will match the decorated method. The path part can be a
                    single string or an array of strings. See werkzeug's routing
                    documentation for the format of path expression (
                    http://werkzeug.pocoo.org/docs/routing/ ).
      :param: input_param: An instance of an object that implemented
                    ``RestMethodParam``. When processing a request, the http
                    handler first call the from_request method and then call the
                    decorated method with the result of this call.
      :param: output_param: An instance of an object that implemented
                    ``RestMethodParam``. When processing the result of the
                    call to the decorated method, the http handler first call
                    the `to_response` method with this result and then return
                    the result of this call.
      :param auth: The type of authentication method
      :param cors: The Access-Control-Allow-Origin cors directive value.
      :param bool csrf: Whether CSRF protection should be enabled for the route.
                        Defaults to ``False``

    """

    def decorator(f):
        _routes = []
        for paths, http_method in routes:
            if not isinstance(paths, list):
                paths = [paths]
            _routes.append(([p for p in paths], http_method))
        routing = {
            "csrf": csrf,
            "auth": auth,
            "cors": cors,
            "routes": _routes,
            "input_param": input_param,
            "output_param": output_param,
        }

        @functools.wraps(f)
        def response_wrap(*args, **kw):
            response = f(*args, **kw)
            return response

        response_wrap.routing = routing
        response_wrap.original_func = f
        return response_wrap

    return decorator
Decorator marking the decorated method as being a handler for
      REST requests. The method must be part of a component inheriting from
    ``base.rest.service``.

      :param routes: list of tuple (path, http method). path is a string or
                    array.
                    Each tuple determines which http requests and http method
                    will match the decorated method. The path part can be a
                    single string or an array of strings. See werkzeug's routing
                    documentation for the format of path expression (
                    http://werkzeug.pocoo.org/docs/routing/ ).
      :param: input_param: An instance of an object that implemented
                    ``RestMethodParam``. When processing a request, the http
                    handler first call the from_request method and then call the
                    decorated method with the result of this call.
      :param: output_param: An instance of an object that implemented
                    ``RestMethodParam``. When processing the result of the
                    call to the decorated method, the http handler first call
                    the `to_response` method with this result and then return
                    the result of this call.
      :param auth: The type of authentication method
      :param cors: The Access-Control-Allow-Origin cors directive value.
      :param bool csrf: Whether CSRF protection should be enabled for the route.
                        Defaults to ``False``

    
Decorator marking the decorated method as being a handler for
REST requests. The method must be part of a component inheriting from
``base.rest.service``.

:param routes: list of tuple (path, http method). path is a string or
array.
Each tuple determines which http requests and http method
will match the decorated method. The path part can be a
single string or an array of strings.
Decorator marking the decorated method as being a handler for REST requests . The method must be part of a component inheriting from ` ` base . rest . service ` ` . : param routes : list of tuple ( path http method ) . path is a string or array . Each tuple determines which http requests and http method will match the decorated method . The path part can be a single string or an array of strings .
def method(
    routes, input_param=None, output_param=None, auth=None, cors=None, csrf=False
):
    def decorator(f):
        _routes = []
        for paths, http_method in routes:
            if not isinstance(paths, list):
                paths = [paths]
            _routes.append(([p for p in paths], http_method))
        routing = {
            "csrf": csrf,
            "auth": auth,
            "cors": cors,
            "routes": _routes,
            "input_param": input_param,
            "output_param": output_param,
        }
        @functools.wraps(f)
        def response_wrap(*args, **kw):
            response = f(*args, **kw)
            return response
        response_wrap.routing = routing
        response_wrap.original_func = f
        return response_wrap
    return decorator
def method ( routes , input_param = None , output_param = None , auth = None , cors = None , csrf = False ) : def decorator ( f ) : _routes = [ ] for paths , http_method in routes : if not isinstance ( paths , list ) : paths = [ paths ] _routes . append ( ( [ p for p in paths ] , http_method ) ) routing = { "csrf" : csrf , "auth" : auth , "cors" : cors , "routes" : _routes , "input_param" : input_param , "output_param" : output_param , } @ functools . wraps ( f ) def response_wrap ( * args , ** kw ) : response = f ( * args , ** kw ) return response response_wrap . routing = routing response_wrap . original_func = f return response_wrap return decorator
Decorator marking the decorated method as being a handler for
REST requests.
Decorator marking the decorated method as being a handler for REST requests .
"""Decorator marking the decorated method as being a handler for
      REST requests. The method must be part of a component inheriting from
    ``base.rest.service``.

      :param routes: list of tuple (path, http method). path is a string or
                    array.
                    Each tuple determines which http requests and http method
                    will match the decorated method. The path part can be a
                    single string or an array of strings. See werkzeug's routing
                    documentation for the format of path expression (
                    http://werkzeug.pocoo.org/docs/routing/ ).
      :param: input_param: An instance of an object that implemented
                    ``RestMethodParam``. When processing a request, the http
                    handler first call the from_request method and then call the
                    decorated method with the result of this call.
      :param: output_param: An instance of an object that implemented
                    ``RestMethodParam``. When processing the result of the
                    call to the decorated method, the http handler first call
                    the `to_response` method with this result and then return
                    the result of this call.
      :param auth: The type of authentication method
      :param cors: The Access-Control-Allow-Origin cors directive value.
      :param bool csrf: Whether CSRF protection should be enabled for the route.
                        Defaults to ``False``

    """
routes
input_param
output_param
auth
cors
csrf