def role_required(role_name=None):
def _role_required(http_method_handler):<EOL><INDENT>@wraps(http_method_handler)<EOL>def secure_http_method_handler(self, *args, **kwargs):<EOL><INDENT>if role_name is None:<EOL><INDENT>_message = "<STR_LIT>"<EOL>authorization_error = prestans.exception.AuthorizationError(_message)<EOL>authorization_error.request = self.request<EOL>raise authorization_error<EOL><DEDENT>if not self.__provider_config__.authentication:<EOL><INDENT>_message = "<STR_LIT>"<EOL>authentication_error = prestans.exception.AuthenticationError(_message)<EOL>authentication_error.request = self.request<EOL>raise authentication_error<EOL><DEDENT>if not self.__provider_config__.authentication.current_user_has_role(role_name):<EOL><INDENT>authorization_error = prestans.exception.AuthorizationError(role_name)<EOL>authorization_error.request = self.request<EOL>raise authorization_error<EOL><DEDENT>http_method_handler(self, *args, **kwargs)<EOL><DEDENT>return wraps(http_method_handler)(secure_http_method_handler)<EOL><DEDENT>return _role_required<EOL>
Authenticates a HTTP method handler based on a provided role

With a little help from Peter Cole's Blog
http://mrcoles.com/blog/3-decorator-examples-and-awesome-python/