mbr / flask-kvsession

A drop-in replacement for Flask's session handling using server-side sessions.
http://pythonhosted.org/Flask-KVSession/
MIT License
168 stars 53 forks source link

Table already defined on this metadata instance #39

Closed avilaton closed 8 years ago

avilaton commented 8 years ago

I am using kvsession in a flask app and it works as expected. I ran into this while running tests:

Traceback (most recent call last):
  File "/home/user/project/tests/base.py", line 20, in setUpClass
    cls.app = get_app('testing')
  File "/home/user/project/__init__.py", line 30, in get_app
    session_store = SQLAlchemyStore(engine, db.Model.metadata, 'kvsession')
  File "/home/user/.virtualenvs/project/local/lib/python2.7/site-packages/simplekv/db/sql.py", line 21, in __init__
    Column('value', LargeBinary, nullable=False)
  File "/home/user/.virtualenvs/project/local/lib/python2.7/site-packages/sqlalchemy/sql/schema.py", line 398, in __new__
    "existing Table object." % key)
InvalidRequestError: Table 'kvsession' is already defined for this MetaData instance.  Specify 'extend_existing=True' to redefine options and columns on an existing Table object.

It somehow happens because the tests call the initialization twice. I could not work around this, any ideas?

avilaton commented 8 years ago

Looks like this issue belongs to simplekv. Closing.