'Return true if the current user has permission on this
folder. Return the string \'ALL\' if the user has all rights.'

def has_generic_permission(self, request, permission_type):

    user = request.user
    if (not user.is_authenticated()):
        return False
    elif user.is_superuser:
        return True
    elif (user == self.owner):
        return True
    else:
        if ((not hasattr(self, u'permission_cache')) or (permission_type not in self.permission_cache) or (request.user.pk != self.permission_cache[u'user'].pk)):
            if ((not hasattr(self, u'permission_cache')) or (request.user.pk != self.permission_cache[u'user'].pk)):
                self.permission_cache = {u'user': request.user}
            func = getattr(FolderPermission.objects, (u'get_%s_id_list' % permission_type))
            permission = func(user)
            if (permission == u'All'):
                self.permission_cache[permission_type] = True
                self.permission_cache[u'read'] = True
                self.permission_cache[u'edit'] = True
                self.permission_cache[u'add_children'] = True
            else:
                self.permission_cache[permission_type] = (self.id in permission)
        return self.permission_cache[permission_type]
