(*methods)
return decorator(check_methods)
Restricts access to the function depending on HTTP method

    Example:

    .. code-block:: python

        from pylons.decorators import rest

        class SomeController(BaseController):

            @rest.restrict('GET')
            def comment(self, id):
Restricts access to the function depending on HTTP method
Restricts access to the function depending on HTTP method
def restrict(*methods):
    """Restricts access to the function depending on HTTP method

    Example:

    .. code-block:: python

        from pylons.decorators import rest

        class SomeController(BaseController):

            @rest.restrict('GET')
            def comment(self, id):

    """
    def check_methods(func, *args, **kwargs):
        """Wrapper for restrict"""
        if get_pylons(args).request.method not in methods:
            log.debug("Method not allowed by restrict")
            abort(405, headers=[('Allow', ','.join(methods))])
        return func(*args, **kwargs)
    return decorator(check_methods)
def restrict ( * methods ) : def check_methods ( func , * args , * * kwargs ) : """Wrapper for restrict""" if get_pylons ( args ) . request . method not in methods : log . debug ( "Method not allowed by restrict" ) abort ( 405 , headers = [ ( 'Allow' , ',' . join ( methods ) ) ] ) return func ( * args , * * kwargs ) return decorator ( check_methods )