# Path: ziggurat_foundations/models/base.py
# def get_db_session(self, session=None):
#     """
#     Attempts to return session via get_db_session utility function
#     :meth:`~ziggurat_foundations.models.get_db_session`
# 
#     :param session:
#     :return:
#     """
#     return get_db_session(session, self)


from collections import namedtuple
from .models.base import get_db_session
        from pyramid.authorization import Allow, Deny, ALL_PERMISSIONS
        from pyramid.security import Allow, Deny, ALL_PERMISSIONS
import sqlalchemy as sa
ANY_PERMISSION = ANY_PERMISSION_CLS()

PermissionTuple = namedtuple(
    "PermissionTuple",
    ["user", "perm_name", "type", "group", "resource", "owner", "allowed"],
)


def resource_permissions_for_users(
    models_proxy,
    perm_names,
    resource_ids=None,
    user_ids=None,
    group_ids=None,
    resource_types=None,
    limit_group_permissions=False,
    skip_user_perms=False,
    skip_group_perms=False,
    db_session=None,
):
    """
    Returns permission tuples that match one of passed permission names
    perm_names - list of permissions that can be matched
    user_ids - restrict to specific users
    group_ids - restrict to specific groups
    resource_ids - restrict to specific resources
    limit_group_permissions - should be used if we do not want to have
    user objects returned for group permissions, this might cause performance
    issues for big groups
    """

# Path: ziggurat_foundations/models/base.py
# def get_db_session(self, session=None):
#     """
#     Attempts to return session via get_db_session utility function
#     :meth:`~ziggurat_foundations.models.get_db_session`
# 
#     :param session:
#     :return:
#     """
#     return get_db_session(session, self)


# Path: ziggurat_foundations/permissions.py
from collections import namedtuple
from .models.base import get_db_session
        from pyramid.authorization import Allow, Deny, ALL_PERMISSIONS
        from pyramid.security import Allow, Deny, ALL_PERMISSIONS
import sqlalchemy as sa

ANY_PERMISSION = ANY_PERMISSION_CLS()

PermissionTuple = namedtuple(
    "PermissionTuple",
    ["user", "perm_name", "type", "group", "resource", "owner", "allowed"],
)


def resource_permissions_for_users(
    models_proxy,
    perm_names,
    resource_ids=None,
    user_ids=None,
    group_ids=None,
    resource_types=None,
    limit_group_permissions=False,
    skip_user_perms=False,
    skip_group_perms=False,
    db_session=None,
):
    """
    Returns permission tuples that match one of passed permission names
    perm_names - list of permissions that can be matched
    user_ids - restrict to specific users
    group_ids - restrict to specific groups
    resource_ids - restrict to specific resources
    limit_group_permissions - should be used if we do not want to have
    user objects returned for group permissions, this might cause performance
    issues for big groups
    """

    db_session = get_db_session(db_session)