Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problems on working with sa-continuum #77

Closed
onlygecko opened this issue Nov 2, 2014 · 1 comment
Closed

Problems on working with sa-continuum #77

onlygecko opened this issue Nov 2, 2014 · 1 comment

Comments

@onlygecko
Copy link

Hello,

the example on the documentation page seems to be easy to run, but somehow I'm not getting it. Could someone show me, what I'm doing wrong?

import sqlalchemy as sa
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import sessionmaker
from sqlalchemy import create_engine
from sqlalchemy_continuum import make_versioned

engine = create_engine('sqlite:////tmp/test.sql', echo=True)
Base = declarative_base()

make_versioned()

class Article(Base):
    __versioned__ = {}
    __tablename__ = 'article'

    id = sa.Column(sa.Integer, primary_key=True, autoincrement=True)
    name = sa.Column(sa.Unicode(255))
    content = sa.Column(sa.UnicodeText)

# after you have defined all your models, call configure_mappers:
sa.orm.configure_mappers()

Base.metadata.create_all(bind=engine)

Session = sessionmaker(bind=engine)
session = Session()

article = Article(name=u'Some article')
session.add(article)
session.commit()

The error I'm getting ist the following:
sqlalchemy_continuum.exc.ImproperlyConfigured: Could not build relationship between Transaction and User. User was not found in declarative class registry. Either configure VersioningManager to use different user class or disable this relationship

Thanks for your anwsers in advance. Peter

@onlygecko
Copy link
Author

It's essential to pass the argument 'user_cls=None' to make_versioned() to run this example. It was hidden in the documentation.

make_versioned(user_cls=None)

m3talstorm added a commit to m3talstorm/sqlalchemy-continuum that referenced this issue Oct 25, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant