def model_query(context, model, *args, **kwargs):
    session = kwargs.get('session') or get_session()

    return session.query(model, *args)
Query helper that accounts for context's `read_deleted` field.
dataset/ETHPy150Open openstack/ec2-api/ec2api/db/sqlalchemy/api.py/model_query