# Path: jarr/bootstrap.py
# def is_secure_served():
# def init_logging(log_path=None, log_level=logging.INFO, modules=(),
#                  log_format='%(asctime)s %(levelname)s %(message)s'):
# def init_db(echo=False):
# def init_models():
# def commit_pending_sql(*args, **kwargs):
# def rollback_pending_sql(*args, **kwargs):
# REDIS_CONN = Redis(host=conf.db.redis.host,
#                    db=conf.db.redis.db,
#                    port=conf.db.redis.port)


import logging
import dateutil.parser
from datetime import timezone
from sqlalchemy import and_, or_
from werkzeug.exceptions import Forbidden, NotFound, Unauthorized
from jarr.bootstrap import Base, session
            attrs[self._user_id_key] = self.user_id
        if not (self._user_id_key is None or self._user_id_key in attrs
                or self.user_id is None):
            raise Unauthorized("You must provide user_id one way or another")

        obj = self._db_cls(**attrs)
        session.add(obj)
        session.flush()
        session.commit()
        return obj

    def read(self, **filters):
        return self._get(**filters)

    def update(self, filters, attrs, return_objs=False, commit=True):
        if not attrs:
            logger.error("nothing to update, doing nothing")
            result, commit = {}, False
        else:
            result = self._get(**filters).update(attrs,
                                                 synchronize_session=False)
        if commit:
            session.flush()
            session.commit()
        if return_objs:
            return self._get(**filters)
        return result

    def delete(self, obj_id, commit=True):
        obj = self.get(id=obj_id)

# Path: jarr/bootstrap.py
# def is_secure_served():
# def init_logging(log_path=None, log_level=logging.INFO, modules=(),
#                  log_format='%(asctime)s %(levelname)s %(message)s'):
# def init_db(echo=False):
# def init_models():
# def commit_pending_sql(*args, **kwargs):
# def rollback_pending_sql(*args, **kwargs):
# REDIS_CONN = Redis(host=conf.db.redis.host,
#                    db=conf.db.redis.db,
#                    port=conf.db.redis.port)


# Path: jarr/controllers/abstract.py
import logging
import dateutil.parser
from datetime import timezone
from sqlalchemy import and_, or_
from werkzeug.exceptions import Forbidden, NotFound, Unauthorized
from jarr.bootstrap import Base, session

            attrs[self._user_id_key] = self.user_id
        if not (self._user_id_key is None or self._user_id_key in attrs
                or self.user_id is None):
            raise Unauthorized("You must provide user_id one way or another")

        obj = self._db_cls(**attrs)
        session.add(obj)
        session.flush()
        session.commit()
        return obj

    def read(self, **filters):
        return self._get(**filters)

    def update(self, filters, attrs, return_objs=False, commit=True):
        if not attrs:
            logger.error("nothing to update, doing nothing")
            result, commit = {}, False
        else:
            result = self._get(**filters).update(attrs,
                                                 synchronize_session=False)
        if commit:
            session.flush()
            session.commit()
        if return_objs:
            return self._get(**filters)
        return result

    def delete(self, obj_id, commit=True):
        obj = self.get(id=obj_id)

        session.delete(obj)