'Return an instance of
:class:`pyramid.security.ACLAllowed` instance if the policy
permits access, return an instance of
:class:`pyramid.security.ACLDenied` if not.'

def permits(self, context, principals, permission):

    acl = '<No    ACL    found    on    any    object    in    resource    lineage>'
    for location in lineage(context):
        try:
            acl = location.__acl__
        except AttributeError:
            continue
        if (acl and callable(acl)):
            acl = acl()
        for ace in acl:
            (ace_action, ace_principal, ace_permissions) = ace
            if (ace_principal in principals):
                if (not is_nonstr_iter(ace_permissions)):
                    ace_permissions = [ace_permissions]
                if (permission in ace_permissions):
                    if (ace_action == Allow):
                        return ACLAllowed(ace, acl, permission, principals, location)
                    else:
                        return ACLDenied(ace, acl, permission, principals, location)
    return ACLDenied('<default    deny>', acl, permission, principals, context)
