from flask import flash, redirect,url_for,g
import functools


def has_access(f):
    """
        Use this decorator to allow access only to security
        defined permissions, use it only on BaseView classes.
    """

    def wraps(self, *args, **kwargs):
        permission_str = "can_" + f.__name__
        if self.appbuilder.sm.has_access(permission_str, self.__class__.__name__):
            return f(self, *args, **kwargs)
        else:
            flash("Access is Denied %s %s" % (f.__name__, self.__class__.__name__), "danger")
        return redirect(url_for(self.appbuilder.sm.auth_view.__class__.__name__ + ".login"))
    return wraps


def permission_name(name):
    """
        Use this decorator to override the name of the permission.
        has_access will use the methods name has the permission name
        if you want to override this add this decorator to your methods.
        This is useful if you want to aggregate methods to permissions

        It will add and '_permission_name' attribute to your method
        that will be inspected by BaseView to collect your view's
        permissions.

        :param name:
            The name of the permission to override
    """
    def wrap(f):
        return f
    wrap._permission_name = name
    return wrap
    

@@ -1225,25 +1225,75 @@
     
-return f%0A    wrap
+print %22PERMISSION NAME URLS=%7B0%7D%22.format(f._urls)%0A        %0A        f
 ._pe
@@ -1309,24 +1309,41 @@
 name = name%0A
+        return f%0A
     return w

Update decorators.py