# 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/utils.py
# def version_class(model):
#     """
#     Return the version class for given SQLAlchemy declarative model class.
# 
#     ::
# 
#         version_class(Article)  # ArticleVersion class
# 
# 
#     :param model: SQLAlchemy declarative model class
# 
#     .. seealso:: :func:`parent_class`
#     """
#     manager = get_versioning_manager(model)
#     try:
#         return manager.version_class_map[model]
#     except KeyError:
#         return model
# 
# def version_obj(session, parent_obj):
#     manager = get_versioning_manager(parent_obj)
#     uow = manager.unit_of_work(session)
#     for version_obj in uow.version_session:
#         if (
#             parent_class(version_obj.__class__) == parent_obj.__class__ and
#             identity(version_obj)[:-1] == identity(parent_obj)
#         ):
#             return version_obj


import sqlalchemy as sa
from sqlalchemy.ext.hybrid import hybrid_property
from sqlalchemy.inspection import inspect
from sqlalchemy_utils import JSONType, generic_relationship
from .base import Plugin
from ..factory import ModelFactory
from ..utils import version_class, version_obj
            Activity.target == article
        )
    )



.. _activity stream specification:
    http://www.activitystrea.ms
.. _generic relationships:
    https://sqlalchemy-utils.readthedocs.io/en/latest/generic_relationship.html
"""




class ActivityBase(object):
    id = sa.Column(
        sa.BigInteger,
        sa.schema.Sequence('activity_id_seq'),
        primary_key=True,
        autoincrement=True
    )

    verb = sa.Column(sa.Unicode(255))

    @hybrid_property
    def actor(self):
        return self.transaction.user



# 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/utils.py
# def version_class(model):
#     """
#     Return the version class for given SQLAlchemy declarative model class.
# 
#     ::
# 
#         version_class(Article)  # ArticleVersion class
# 
# 
#     :param model: SQLAlchemy declarative model class
# 
#     .. seealso:: :func:`parent_class`
#     """
#     manager = get_versioning_manager(model)
#     try:
#         return manager.version_class_map[model]
#     except KeyError:
#         return model
# 
# def version_obj(session, parent_obj):
#     manager = get_versioning_manager(parent_obj)
#     uow = manager.unit_of_work(session)
#     for version_obj in uow.version_session:
#         if (
#             parent_class(version_obj.__class__) == parent_obj.__class__ and
#             identity(version_obj)[:-1] == identity(parent_obj)
#         ):
#             return version_obj


# Path: sqlalchemy_continuum/plugins/activity.py
import sqlalchemy as sa
from sqlalchemy.ext.hybrid import hybrid_property
from sqlalchemy.inspection import inspect
from sqlalchemy_utils import JSONType, generic_relationship
from .base import Plugin
from ..factory import ModelFactory
from ..utils import version_class, version_obj

            Activity.target == article
        )
    )



.. _activity stream specification:
    http://www.activitystrea.ms
.. _generic relationships:
    https://sqlalchemy-utils.readthedocs.io/en/latest/generic_relationship.html
"""




class ActivityBase(object):
    id = sa.Column(
        sa.BigInteger,
        sa.schema.Sequence('activity_id_seq'),
        primary_key=True,
        autoincrement=True
    )

    verb = sa.Column(sa.Unicode(255))

    @hybrid_property
    def actor(self):
        return self.transaction.user



class ActivityFactory(ModelFactory):