Trying to use SAFRS i've structured my App to have separated models, but when i do so I somehow get session ownership issues like the ones described here: https://stackoverflow.com/questions/24291933/sqlalchemy-object-already-attached-to-session
└[cochabamba] python3 server.py 15:12:19
/home/xaiki/src/Urissane/cerberus/python/virtualenv/lib/python3.7/site-packages/safrs/swagger_doc.py:34: YAMLLoadWarning: calling yaml.load() without Loader=... is deprecated, as the default Loader is unsafe. Please read https://msg.pyyaml.org/load for full details.
yaml_doc = yaml.load(raw_doc)
Starting API: http://0.0.0.0:5000/api
Traceback (most recent call last):
File "server.py", line 17, in <module>
db.session.add(user)
File "/home/xaiki/src/Urissane/cerberus/python/virtualenv/lib/python3.7/site-packages/sqlalchemy/orm/scoping.py", line 162, in do
return getattr(self.registry(), name)(*args, **kwargs)
File "/home/xaiki/src/Urissane/cerberus/python/virtualenv/lib/python3.7/site-packages/sqlalchemy/orm/session.py", line 1948, in add
self._save_or_update_state(state)
File "/home/xaiki/src/Urissane/cerberus/python/virtualenv/lib/python3.7/site-packages/sqlalchemy/orm/session.py", line 1961, in _save_or_update_state
self._save_or_update_impl(state)
File "/home/xaiki/src/Urissane/cerberus/python/virtualenv/lib/python3.7/site-packages/sqlalchemy/orm/session.py", line 2311, in _save_or_update_impl
self._update_impl(state)
File "/home/xaiki/src/Urissane/cerberus/python/virtualenv/lib/python3.7/site-packages/sqlalchemy/orm/session.py", line 2294, in _update_impl
to_attach = self._before_attach(state, obj)
File "/home/xaiki/src/Urissane/cerberus/python/virtualenv/lib/python3.7/site-packages/sqlalchemy/orm/session.py", line 2382, in _before_attach
% (state_str(state), state.session_id, self.hash_key)
sqlalchemy.exc.InvalidRequestError: Object '<User at 0x7f0fa61f3c50>' is already attached to session '1' (this is '2')
Safrs autocommits objects when they are instantiated.
This may be circumvented by setting
SAFRSBase.db_commit = False
I Will have to verify this later tho( i m on my phone now)