Esempio n. 1
0
def error403(exc, request):
    outstanding = []

    if request.user.can(request.permission):
        all_outstanding = outstanding_principals(
            request.permission, request.context, request)
        for altset in all_outstanding:
            if all(p for p in altset if p.startswith(UPGRADABLE_PRINCIPALS)):
                outstanding.append(tuple(altset))

    outstanding = list(set(outstanding))  # Unique-ify
    outstanding.sort(key=len)

    default_msg = u"I'm afraid I can't let you do that"
    return error_view(exc, request, default_msg,
                      outstanding_principals=outstanding)
Esempio n. 2
0
def error403(context, request):
    outstanding = None

    if request.user.can(request.permission):
        from floof.lib.authz import UPGRADABLE_PRINCIPALS
        all_outstanding = outstanding_principals(
                request.permission, request.context, request)
        outstanding = []
        for altset in all_outstanding:
            f = lambda x: x.startswith(UPGRADABLE_PRINCIPALS)
            if all(map(f, altset)):
                outstanding.append(altset)

    return _error_view(context, request,
                       default_message="I'm afraid I can't let you do that",
                       outstanding_principals=outstanding)