def has_access(f):
if hasattr(f, '<STR_LIT>'):<EOL><INDENT>permission_str = f._permission_name<EOL><DEDENT>else:<EOL><INDENT>permission_str = f.__name__<EOL><DEDENT>def wraps(self, *args, **kwargs):<EOL><INDENT>permission_str = PERMISSION_PREFIX + f._permission_name<EOL>if self.appbuilder.sm.has_access(<EOL>permission_str,<EOL>self.__class__.__name__<EOL>):<EOL><INDENT>return f(self, *args, **kwargs)<EOL><DEDENT>else:<EOL><INDENT>log.warning(<EOL>LOGMSG_ERR_SEC_ACCESS_DENIED.format(<EOL>permission_str,<EOL>self.__class__.__name__<EOL>)<EOL>)<EOL>flash(as_unicode(FLAMSG_ERR_SEC_ACCESS_DENIED), "<STR_LIT>")<EOL><DEDENT>return redirect(<EOL>url_for(<EOL>self.appbuilder.sm.auth_view.__class__.__name__ + "<STR_LIT>",<EOL>next=request.url<EOL>)<EOL>)<EOL><DEDENT>f._permission_name = permission_str<EOL>return functools.update_wrapper(wraps, f)<EOL>
Use this decorator to enable granular security permissions to your methods.
Permissions will be associated to a role, and roles are associated to users.

By default the permission's name is the methods name.