# Path: sqlalchemy_continuum/factory.py
# class ModelFactory(object):
#     model_name = None
# 
#     def __call__(self, manager):
#         """
#         Create model class but only if it doesn't already exist
#         in declarative model registry.
#         """
#         Base = manager.declarative_base
#         try:
#             registry = Base.registry._class_registry
#         except AttributeError:  # SQLAlchemy < 1.4
#             registry = Base._decl_class_registry
#         if self.model_name not in registry:
#             return self.create_class(manager)
#         return registry[self.model_name]


from datetime import datetime
from functools import partial
    from collections import OrderedDict
    from ordereddict import OrderedDict
from sqlalchemy.ext.compiler import compiles
from .dialects.postgresql import (
    CreateTemporaryTransactionTableSQL,
    InsertTemporaryTransactionSQL,
    TransactionTriggerSQL
)
from .exc import ImproperlyConfigured
from .factory import ModelFactory
import six
import sqlalchemy as sa

def create_triggers(cls):
    sa.event.listen(
        cls.__table__,
        'after_create',
        sa.schema.DDL(
            procedure_sql.format(
                temporary_transaction_sql=CreateTemporaryTransactionTableSQL(),
                insert_temporary_transaction_sql=(
                    InsertTemporaryTransactionSQL(
                        transaction_id_values='NEW.id'
                    )
                ),
            )
        )
    )
    sa.event.listen(
        cls.__table__,
        'after_create',
        sa.schema.DDL(str(TransactionTriggerSQL(cls)))
    )
    sa.event.listen(
        cls.__table__,
        'after_drop',
        sa.schema.DDL(
            'DROP FUNCTION IF EXISTS transaction_temp_table_generator()'
        )
    )



# Path: sqlalchemy_continuum/factory.py
# class ModelFactory(object):
#     model_name = None
# 
#     def __call__(self, manager):
#         """
#         Create model class but only if it doesn't already exist
#         in declarative model registry.
#         """
#         Base = manager.declarative_base
#         try:
#             registry = Base.registry._class_registry
#         except AttributeError:  # SQLAlchemy < 1.4
#             registry = Base._decl_class_registry
#         if self.model_name not in registry:
#             return self.create_class(manager)
#         return registry[self.model_name]


# Path: sqlalchemy_continuum/transaction.py
from datetime import datetime
from functools import partial
    from collections import OrderedDict
    from ordereddict import OrderedDict
from sqlalchemy.ext.compiler import compiles
from .dialects.postgresql import (
    CreateTemporaryTransactionTableSQL,
    InsertTemporaryTransactionSQL,
    TransactionTriggerSQL
)
from .exc import ImproperlyConfigured
from .factory import ModelFactory
import six
import sqlalchemy as sa


def create_triggers(cls):
    sa.event.listen(
        cls.__table__,
        'after_create',
        sa.schema.DDL(
            procedure_sql.format(
                temporary_transaction_sql=CreateTemporaryTransactionTableSQL(),
                insert_temporary_transaction_sql=(
                    InsertTemporaryTransactionSQL(
                        transaction_id_values='NEW.id'
                    )
                ),
            )
        )
    )
    sa.event.listen(
        cls.__table__,
        'after_create',
        sa.schema.DDL(str(TransactionTriggerSQL(cls)))
    )
    sa.event.listen(
        cls.__table__,
        'after_drop',
        sa.schema.DDL(
            'DROP FUNCTION IF EXISTS transaction_temp_table_generator()'
        )
    )



class TransactionFactory(ModelFactory):