pallets-eco / flask-openid

Flask-OpenID adds openid support to flask applications

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

run example InvalidRequestError: No transaction is begun.

JesseYan opened this issue · comments

on tag:v1.2.5 of master branch, it gets this exception:

Traceback (most recent call last):
File "/Library/Python/2.7/site-packages/flask/app.py", line 1836, in call
return self.wsgi_app(environ, start_response)
File "/Library/Python/2.7/site-packages/flask/app.py", line 1820, in wsgi_app
response = self.make_response(self.handle_exception(e))
File "/Library/Python/2.7/site-packages/flask/app.py", line 1403, in handle_exception
reraise(exc_type, exc_value, tb)
File "/Library/Python/2.7/site-packages/flask/app.py", line 1817, in wsgi_app
response = self.full_dispatch_request()
File "/Library/Python/2.7/site-packages/flask/app.py", line 1477, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/Library/Python/2.7/site-packages/flask/app.py", line 1381, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/Library/Python/2.7/site-packages/flask/app.py", line 1475, in full_dispatch_request
rv = self.dispatch_request()
File "/Library/Python/2.7/site-packages/flask/app.py", line 1461, in dispatch_request
return self.view_functionsrule.endpoint
File "/Users/jesse/software/flask-openid/example/example.py", line 136, in create_profile
db_session.commit()
File "/Library/Python/2.7/site-packages/sqlalchemy/orm/scoping.py", line 157, in do
return getattr(self.registry(), name)(_args, *_kwargs)
File "/Library/Python/2.7/site-packages/sqlalchemy/orm/session.py", line 799, in commit
raise sa_exc.InvalidRequestError("No transaction is begun.")
InvalidRequestError: No transaction is begun.

I guess it may this:
db_session set autocommit=True, then line 136:db_session.commit()
db_session has automatically run commit

just set autocommit=False , this example runs well

Thank you very much for this!

derp, thanks for the easy googleable fix calling .commit() when autocommit=True