def cache_permission(func):
 def wrapper(user, target_object):
  if (user is None):
   user = User.objects.get(username=appsettings.ANONYMOUS_USER_NAME)
  if (target_object is None):
   obj_key = None
  else:
   obj_key = target_object.get_full_slug()
  if (not hasattr(user, 'acl_permissions_cache')):
   user.acl_permissions_cache = {}
  key = (func.__name__, obj_key)
  if (key not in user.acl_permissions_cache):
   user.acl_permissions_cache[key] = func(user, target_object)
  return user.acl_permissions_cache[key]
 return wrapper

def cache_permission ( func ) : def wrapper ( user , target_object ) : if ( user is None ) : user = User . objects . get ( username = appsettings . ANONYMOUS_USER_NAME ) if ( target_object is None ) : obj_key = None else : obj_key = target_object . get_full_slug ( ) if ( not hasattr ( user , 'acl_permissions_cache' ) ) : user . acl_permissions_cache = { } key = ( func . __name__ , obj_key ) if ( key not in user . acl_permissions_cache ) : user . acl_permissions_cache [ key ] = func ( user , target_object ) return user . acl_permissions_cache [ key ] return wrapper
caching for permissions check .