# Path: scribeui_pyramid/modules/app/interfaces.py
# class IDBSession(Interface):
#     pass


from datetime import (
    date,
    datetime
)
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import (
    scoped_session,
    sessionmaker,
)
from sqlalchemy import engine_from_config
from zope.sqlalchemy import ZopeTransactionExtension
from .interfaces import IDBSession
import sqlalchemy as sa
# -*- coding: utf-8 -*-


DBSession = scoped_session(sessionmaker(extension=ZopeTransactionExtension()))
Base = declarative_base()


def get_session(request):
    if request.registry.queryUtility(IDBSession):
        session = request.registry.getUtility(IDBSession)
        return session
    else:
        raise Exception(
            'You need to register a DBSession to IDBSession interface'
        )


def init_sqla(settings):
    engine = engine_from_config(settings, 'sqlalchemy.')
    DBSession.configure(bind=engine)
    Base.metadata.bind = engine


class BaseMixin(object):

    query = DBSession.query_property()

    def __props__(self, convert_date=False):
        props = {}
        blacklist = ['password']

# Path: scribeui_pyramid/modules/app/interfaces.py
# class IDBSession(Interface):
#     pass


# Path: scribeui_pyramid/modules/app/sqla.py
from datetime import (
    date,
    datetime
)
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import (
    scoped_session,
    sessionmaker,
)
from sqlalchemy import engine_from_config
from zope.sqlalchemy import ZopeTransactionExtension
from .interfaces import IDBSession
import sqlalchemy as sa

# -*- coding: utf-8 -*-


DBSession = scoped_session(sessionmaker(extension=ZopeTransactionExtension()))
Base = declarative_base()


def get_session(request):
    if request.registry.queryUtility(IDBSession):
        session = request.registry.getUtility(IDBSession)
        return session
    else:
        raise Exception(
            'You need to register a DBSession to IDBSession interface'
        )


def init_sqla(settings):
    engine = engine_from_config(settings, 'sqlalchemy.')
    DBSession.configure(bind=engine)
    Base.metadata.bind = engine


class BaseMixin(object):

    query = DBSession.query_property()

    def __props__(self, convert_date=False):
        props = {}
        blacklist = ['password']

        for key in self.__dict__: