Returns true if the one of the groups in the request has the requested
    permission.

    The function takes a request, a permission to check for and a context. A
    context is a sequence of ACL tuples which consist of a Allow/Deny action,
    a group, and a sequence of permissions for that ACL group. For example::

        context = [(Permission.Allow, 'view_group', ('view',)),
                   (Permission.Allow, 'edit_group', ('view', 'edit')),]

    ACL tuple sequences are checked in order, with the first tuple that matches
    the group the user is a member of, and includes the permission passed to
    the function, to be the matching ACL group. If no ACL group is found, the
    function returns False.

    Groups and permissions need only be immutable objects, so can be strings,
    numbers, enumerations, or other immutable objects.

    Args:
        request: aiohttp Request object
        permission: The specific permission requested.
        context: A sequence of ACL tuples

    Returns:
        The function gets the groups by calling get_user_groups() and returns
        true if the groups are Allowed the requested permission, false
        otherwise.

    Raises:
        RuntimeError: If the ACL middleware is not installed

async def get_permitted(request, permission, context):
    """Returns true if the one of the groups in the request has the requested
    permission.

    The function takes a request, a permission to check for and a context. A
    context is a sequence of ACL tuples which consist of a Allow/Deny action,
    a group, and a sequence of permissions for that ACL group. For example::

        context = [(Permission.Allow, 'view_group', ('view',)),
                   (Permission.Allow, 'edit_group', ('view', 'edit')),]

    ACL tuple sequences are checked in order, with the first tuple that matches
    the group the user is a member of, and includes the permission passed to
    the function, to be the matching ACL group. If no ACL group is found, the
    function returns False.

    Groups and permissions need only be immutable objects, so can be strings,
    numbers, enumerations, or other immutable objects.

    Args:
        request: aiohttp Request object
        permission: The specific permission requested.
        context: A sequence of ACL tuples

    Returns:
        The function gets the groups by calling get_user_groups() and returns
        true if the groups are Allowed the requested permission, false
        otherwise.

    Raises:
        RuntimeError: If the ACL middleware is not installed
    """

    groups = await get_user_groups(request)
    if groups is None:
        return False

    for action, group, permissions in context:
        if group in groups:
            if permission in permissions:
                return action == Permission.Allow

    return False