Can not add user in SQL resolver

Am trying to add user or edit users in a “users” database located in the
same mysql server as privacyidea.
I have tried to add/edit user both within webgui and API which always
result in the error message
’Session’ object has no attribute ‘_model_changes’"

[2017-03-23 11:58:28,091][3165][140013674645248][ERROR][privacyidea.app:1423
] Exception on /user/ [POST]
Traceback (most recent call last):
File “/usr/lib/python2.7/dist-packages/flask/app.py”, line 1817, in
wsgi_app
response = self.full_dispatch_request()
File “/usr/lib/python2.7/dist-packages/flask/app.py”, line 1477, in
full_dispatch_request
rv = self.handle_user_exception(e)
File “/usr/lib/python2.7/dist-packages/flask/app.py”, line 1381, in
handle_user_exception
reraise(exc_type, exc_value, tb)
File “/usr/lib/python2.7/dist-packages/flask/app.py”, line 1475, in
full_dispatch_request
rv = self.dispatch_request()
File “/usr/lib/python2.7/dist-packages/flask/app.py”, line 1461, in
dispatch_request
return self.view_functionsrule.endpoint
File “/usr/lib/python2.7/dist-packages/privacyidea/api/lib/prepolicy.py”,
line 115, in policy_wrapper
return wrapped_function(*args, **kwds)
File “/usr/lib/python2.7/dist-packages/privacyidea/api/auth.py”, line 313,
in decorated_function
return f(*args, **kwargs)
File “/usr/lib/python2.7/dist-packages/privacyidea/api/user.py”, line 173,
in create_user_api
r = create_user(resolvername, attributes, password=password)
File “/usr/lib/python2.7/dist-packages/privacyidea/lib/log.py”, line 187,
in log_wrapper
f_result = func(*args, **kwds)
File “/usr/lib/python2.7/dist-packages/privacyidea/lib/user.py”, line 485,
in create_user
uid = y.add_user(attributes)
File
"/usr/lib/python2.7/dist-packages/privacyidea/lib/resolvers/SQLIdResolver.py"
, line 709, in add_user
self.db.commit()
File “/usr/lib/python2.7/dist-packages/sqlsoup.py”, line 268, in commit
self.session.commit()
File “/usr/lib/python2.7/dist-packages/sqlalchemy/orm/scoping.py”, line
150, in do
return getattr(self.registry(), name)(*args, **kwargs)
File “/usr/lib/python2.7/dist-packages/sqlalchemy/orm/session.py”, line
813, in commit
self.transaction.commit()
File “/usr/lib/python2.7/dist-packages/sqlalchemy/orm/session.py”, line
392, in commit
self._prepare_impl()
File “/usr/lib/python2.7/dist-packages/sqlalchemy/orm/session.py”, line
361, in _prepare_impl
self.session.dispatch.before_commit(self.session)
File “/usr/lib/python2.7/dist-packages/sqlalchemy/event/attr.py”, line 218
, in call
fn(*args, **kw)
File “/usr/lib/python2.7/dist-packages/flask_sqlalchemy/init.py”,
line 162, in session_signal_before_commit
d = session._model_changes
AttributeError: ‘Session’ object has no attribute ‘_model_changes’

Machine is a new Ubuntu server 16.04. Privacyidea installed today from
ubuntu repository, v1.18.1.

How do I troubleshoot this error message?

CREATE TABLE users (
userid mediumint(8),
username varchar(255),
email varchar(255),
password varchar(255),
PRIMARY KEY (userid)
);

GET https://aaa.example.com/resolver/users
{
“jsonrpc”: “2.0”,
“signature”: “15622475369983…”,
“versionnumber”: “2.18.1”,
“version”: “privacyIDEA 2.18.1”,
“result”: {
“status”: true,
“value”: {
“users”: {
“type”: “sqlresolver”,
“data”: {
“Map”: “{“userid”: “userid”, “username”: “username”, “email”:
“email”, “password”: “password” }”,
“Encoding”: “”,
“Driver”: “mysql”,
“Database”: “users”,
“Editable”: “1”,
“Server”: “127.0.0.1”,
“Limit”: “500”,
“User”: “users”,
“poolTimeout”: “”,
“Table”: “users”,
“Password”: “ZyV2r1xxxxAO83d”,
“Port”: “3306”
},
“resolvername”: “users”
}
}
},
“time”: 1490270412.660811,
“id”: 1
}

POST https://aaa.example.com/user/

{
“jsonrpc”: “2.0”,
“signature”: “2518239733490006699…”,
“detail”: null,
“version”: “privacyIDEA 2.18.1”,
“result”: {
“status”: false,
“error”: {
“message”: “‘Session’ object has no attribute ‘_model_changes’”,
“code”: -500
}
},
“time”: 1490270564.568782,
“id”: 1
}

Den torsdag 23 mars 2017 kl. 12:08:51 UTC+1 skrev Nicke:>

Am trying to add user or edit users in a “users” database located in the
same mysql server as privacyidea.
I have tried to add/edit user both within webgui and API which always
result in the error message
’Session’ object has no attribute ‘_model_changes’"

[2017-03-23 11:58:28,091][3165][140013674645248][ERROR][privacyidea.app:
1423] Exception on /user/ [POST]
Traceback (most recent call last):
File “/usr/lib/python2.7/dist-packages/flask/app.py”, line 1817, in
wsgi_app
response = self.full_dispatch_request()
File “/usr/lib/python2.7/dist-packages/flask/app.py”, line 1477, in
full_dispatch_request
rv = self.handle_user_exception(e)
File “/usr/lib/python2.7/dist-packages/flask/app.py”, line 1381, in
handle_user_exception
reraise(exc_type, exc_value, tb)
File “/usr/lib/python2.7/dist-packages/flask/app.py”, line 1475, in
full_dispatch_request
rv = self.dispatch_request()
File “/usr/lib/python2.7/dist-packages/flask/app.py”, line 1461, in
dispatch_request
return self.view_functionsrule.endpoint
File “/usr/lib/python2.7/dist-packages/privacyidea/api/lib/prepolicy.py”
, line 115, in policy_wrapper
return wrapped_function(*args, **kwds)
File “/usr/lib/python2.7/dist-packages/privacyidea/api/auth.py”, line
313, in decorated_function
return f(*args, **kwargs)
File “/usr/lib/python2.7/dist-packages/privacyidea/api/user.py”, line
173, in create_user_api
r = create_user(resolvername, attributes, password=password)
File “/usr/lib/python2.7/dist-packages/privacyidea/lib/log.py”, line 187
, in log_wrapper
f_result = func(*args, **kwds)
File “/usr/lib/python2.7/dist-packages/privacyidea/lib/user.py”, line
485, in create_user
uid = y.add_user(attributes)
File
"/usr/lib/python2.7/dist-packages/privacyidea/lib/resolvers/SQLIdResolver.py"
, line 709, in add_user
self.db.commit()
File “/usr/lib/python2.7/dist-packages/sqlsoup.py”, line 268, in commit
self.session.commit()
File “/usr/lib/python2.7/dist-packages/sqlalchemy/orm/scoping.py”, line
150, in do
return getattr(self.registry(), name)(*args, **kwargs)
File “/usr/lib/python2.7/dist-packages/sqlalchemy/orm/session.py”, line
813, in commit
self.transaction.commit()
File “/usr/lib/python2.7/dist-packages/sqlalchemy/orm/session.py”, line
392, in commit
self._prepare_impl()
File “/usr/lib/python2.7/dist-packages/sqlalchemy/orm/session.py”, line
361, in _prepare_impl
self.session.dispatch.before_commit(self.session)
File “/usr/lib/python2.7/dist-packages/sqlalchemy/event/attr.py”, line
218, in call
fn(*args, **kw)
File “/usr/lib/python2.7/dist-packages/flask_sqlalchemy/init.py”,
line 162, in session_signal_before_commit
d = session._model_changes
AttributeError: ‘Session’ object has no attribute ‘_model_changes’

Machine is a new Ubuntu server 16.04. Privacyidea installed today from
ubuntu repository, v1.18.1.

How do I troubleshoot this error message?

Hi Nicke,

you can use this script, to create a SQL DB writable user resolver.

Or take a look at the script to fix your table.

Kind regards
CorneliusAm Donnerstag, 23. März 2017 13:04:45 UTC+1 schrieb Nicke:

CREATE TABLE users (
userid mediumint(8),
username varchar(255),
email varchar(255),
password varchar(255),
PRIMARY KEY (userid)
);

GET https://aaa.example.com/resolver/users
{
“jsonrpc”: “2.0”,
“signature”: “15622475369983…”,
“versionnumber”: “2.18.1”,
“version”: “privacyIDEA 2.18.1”,
“result”: {
“status”: true,
“value”: {
“users”: {
“type”: “sqlresolver”,
“data”: {
“Map”: “{“userid”: “userid”, “username”: “username”, “email”:
“email”, “password”: “password” }”,
“Encoding”: “”,
“Driver”: “mysql”,
“Database”: “users”,
“Editable”: “1”,
“Server”: “127.0.0.1”,
“Limit”: “500”,
“User”: “users”,
“poolTimeout”: “”,
“Table”: “users”,
“Password”: “ZyV2r1xxxxAO83d”,
“Port”: “3306”
},
“resolvername”: “users”
}
}
},
“time”: 1490270412.660811,
“id”: 1
}

POST https://aaa.example.com/user/

{
“jsonrpc”: “2.0”,
“signature”: “2518239733490006699…”,
“detail”: null,
“version”: “privacyIDEA 2.18.1”,
“result”: {
“status”: false,
“error”: {
“message”: “‘Session’ object has no attribute ‘_model_changes’”,
“code”: -500
}
},
“time”: 1490270564.568782,
“id”: 1
}

Den torsdag 23 mars 2017 kl. 12:08:51 UTC+1 skrev Nicke:

Am trying to add user or edit users in a “users” database located in the
same mysql server as privacyidea.
I have tried to add/edit user both within webgui and API which always
result in the error message
’Session’ object has no attribute ‘_model_changes’"

[2017-03-23 11:58:28,091][3165][140013674645248][ERROR][privacyidea.app:
1423] Exception on /user/ [POST]
Traceback (most recent call last):
File “/usr/lib/python2.7/dist-packages/flask/app.py”, line 1817, in
wsgi_app
response = self.full_dispatch_request()
File “/usr/lib/python2.7/dist-packages/flask/app.py”, line 1477, in
full_dispatch_request
rv = self.handle_user_exception(e)
File “/usr/lib/python2.7/dist-packages/flask/app.py”, line 1381, in
handle_user_exception
reraise(exc_type, exc_value, tb)
File “/usr/lib/python2.7/dist-packages/flask/app.py”, line 1475, in
full_dispatch_request
rv = self.dispatch_request()
File “/usr/lib/python2.7/dist-packages/flask/app.py”, line 1461, in
dispatch_request
return self.view_functionsrule.endpoint
File
"/usr/lib/python2.7/dist-packages/privacyidea/api/lib/prepolicy.py",
line 115, in policy_wrapper
return wrapped_function(*args, **kwds)
File “/usr/lib/python2.7/dist-packages/privacyidea/api/auth.py”, line
313, in decorated_function
return f(*args, **kwargs)
File “/usr/lib/python2.7/dist-packages/privacyidea/api/user.py”, line
173, in create_user_api
r = create_user(resolvername, attributes, password=password)
File “/usr/lib/python2.7/dist-packages/privacyidea/lib/log.py”, line
187, in log_wrapper
f_result = func(*args, **kwds)
File “/usr/lib/python2.7/dist-packages/privacyidea/lib/user.py”, line
485, in create_user
uid = y.add_user(attributes)
File
"/usr/lib/python2.7/dist-packages/privacyidea/lib/resolvers/SQLIdResolver.py"
, line 709, in add_user
self.db.commit()
File “/usr/lib/python2.7/dist-packages/sqlsoup.py”, line 268, in commit
self.session.commit()
File “/usr/lib/python2.7/dist-packages/sqlalchemy/orm/scoping.py”,
line 150, in do
return getattr(self.registry(), name)(*args, **kwargs)
File “/usr/lib/python2.7/dist-packages/sqlalchemy/orm/session.py”,
line 813, in commit
self.transaction.commit()
File “/usr/lib/python2.7/dist-packages/sqlalchemy/orm/session.py”,
line 392, in commit
self._prepare_impl()
File “/usr/lib/python2.7/dist-packages/sqlalchemy/orm/session.py”,
line 361, in _prepare_impl
self.session.dispatch.before_commit(self.session)
File “/usr/lib/python2.7/dist-packages/sqlalchemy/event/attr.py”, line
218, in call
fn(*args, **kw)
File “/usr/lib/python2.7/dist-packages/flask_sqlalchemy/init.py”,
line 162, in session_signal_before_commit
d = session._model_changes
AttributeError: ‘Session’ object has no attribute ‘_model_changes’

Machine is a new Ubuntu server 16.04. Privacyidea installed today from
ubuntu repository, v1.18.1.

How do I troubleshoot this error message?

Hello
Thanks for the kind response. The script works and have created a nice
sqlite database for me.
But the problem does still exist, same
’Session’ object has no attribute '_model_changes’
error when trying to add a user to this new sqlite database.

Where do I start when troubleshooting this?

Den måndag 27 mars 2017 kl. 00:00:28 UTC+2 skrev Cornelius Kölbel:>

Hi Nicke,

you can use this script, to create a SQL DB writable user resolver.

https://github.com/privacyidea/privacyidea/blob/master/tools/privacyidea-create-userdb

Or take a look at the script to fix your table.

Kind regards
Cornelius

Am Donnerstag, 23. März 2017 13:04:45 UTC+1 schrieb Nicke:

CREATE TABLE users (
userid mediumint(8),
username varchar(255),
email varchar(255),
password varchar(255),
PRIMARY KEY (userid)
);

GET https://aaa.example.com/resolver/users
{
“jsonrpc”: “2.0”,
“signature”: “15622475369983…”,
“versionnumber”: “2.18.1”,
“version”: “privacyIDEA 2.18.1”,
“result”: {
“status”: true,
“value”: {
“users”: {
“type”: “sqlresolver”,
“data”: {
“Map”: “{“userid”: “userid”, “username”: “username”, “email”:
“email”, “password”: “password” }”,
“Encoding”: “”,
“Driver”: “mysql”,
“Database”: “users”,
“Editable”: “1”,
“Server”: “127.0.0.1”,
“Limit”: “500”,
“User”: “users”,
“poolTimeout”: “”,
“Table”: “users”,
“Password”: “ZyV2r1xxxxAO83d”,
“Port”: “3306”
},
“resolvername”: “users”
}
}
},
“time”: 1490270412.660811,
“id”: 1
}

POST https://aaa.example.com/user/

{
“jsonrpc”: “2.0”,
“signature”: “2518239733490006699…”,
“detail”: null,
“version”: “privacyIDEA 2.18.1”,
“result”: {
“status”: false,
“error”: {
“message”: “‘Session’ object has no attribute ‘_model_changes’”,
“code”: -500
}
},
“time”: 1490270564.568782,
“id”: 1
}

Den torsdag 23 mars 2017 kl. 12:08:51 UTC+1 skrev Nicke:

Am trying to add user or edit users in a “users” database located in the
same mysql server as privacyidea.
I have tried to add/edit user both within webgui and API which always
result in the error message
’Session’ object has no attribute ‘_model_changes’"

[2017-03-23 11:58:28,091][3165][140013674645248][ERROR][privacyidea.app:
1423] Exception on /user/ [POST]
Traceback (most recent call last):
File “/usr/lib/python2.7/dist-packages/flask/app.py”, line 1817, in
wsgi_app
response = self.full_dispatch_request()
File “/usr/lib/python2.7/dist-packages/flask/app.py”, line 1477, in
full_dispatch_request
rv = self.handle_user_exception(e)
File “/usr/lib/python2.7/dist-packages/flask/app.py”, line 1381, in
handle_user_exception
reraise(exc_type, exc_value, tb)
File “/usr/lib/python2.7/dist-packages/flask/app.py”, line 1475, in
full_dispatch_request
rv = self.dispatch_request()
File “/usr/lib/python2.7/dist-packages/flask/app.py”, line 1461, in
dispatch_request
return self.view_functionsrule.endpoint
File
"/usr/lib/python2.7/dist-packages/privacyidea/api/lib/prepolicy.py",
line 115, in policy_wrapper
return wrapped_function(*args, **kwds)
File “/usr/lib/python2.7/dist-packages/privacyidea/api/auth.py”, line
313, in decorated_function
return f(*args, **kwargs)
File “/usr/lib/python2.7/dist-packages/privacyidea/api/user.py”, line
173, in create_user_api
r = create_user(resolvername, attributes, password=password)
File “/usr/lib/python2.7/dist-packages/privacyidea/lib/log.py”, line
187, in log_wrapper
f_result = func(*args, **kwds)
File “/usr/lib/python2.7/dist-packages/privacyidea/lib/user.py”, line
485, in create_user
uid = y.add_user(attributes)
File
"/usr/lib/python2.7/dist-packages/privacyidea/lib/resolvers/SQLIdResolver.py"
, line 709, in add_user
self.db.commit()
File “/usr/lib/python2.7/dist-packages/sqlsoup.py”, line 268, in
commit
self.session.commit()
File “/usr/lib/python2.7/dist-packages/sqlalchemy/orm/scoping.py”,
line 150, in do
return getattr(self.registry(), name)(*args, **kwargs)
File “/usr/lib/python2.7/dist-packages/sqlalchemy/orm/session.py”,
line 813, in commit
self.transaction.commit()
File “/usr/lib/python2.7/dist-packages/sqlalchemy/orm/session.py”,
line 392, in commit
self._prepare_impl()
File “/usr/lib/python2.7/dist-packages/sqlalchemy/orm/session.py”,
line 361, in _prepare_impl
self.session.dispatch.before_commit(self.session)
File “/usr/lib/python2.7/dist-packages/sqlalchemy/event/attr.py”,
line 218, in call
fn(*args, **kw)
File “/usr/lib/python2.7/dist-packages/flask_sqlalchemy/init.py”,
line 162, in session_signal_before_commit
d = session._model_changes
AttributeError: ‘Session’ object has no attribute ‘_model_changes’

Machine is a new Ubuntu server 16.04. Privacyidea installed today from
ubuntu repository, v1.18.1.

How do I troubleshoot this error message?

Hi Nicke

I think we have found this issue and fixed it in the current master branch.


It will be part of release 2.19 in roughly 3 weeks.

Kind regards
CorneliusAm Montag, 27. März 2017 09:08:06 UTC+2 schrieb Nicke:

Hello
Thanks for the kind response. The script works and have created a nice
sqlite database for me.
But the problem does still exist, same
‘Session’ object has no attribute ‘_model_changes’
error when trying to add a user to this new sqlite database.

Where do I start when troubleshooting this?

Den måndag 27 mars 2017 kl. 00:00:28 UTC+2 skrev Cornelius Kölbel:

Hi Nicke,

you can use this script, to create a SQL DB writable user resolver.

https://github.com/privacyidea/privacyidea/blob/master/tools/privacyidea-create-userdb

Or take a look at the script to fix your table.

Kind regards
Cornelius

Am Donnerstag, 23. März 2017 13:04:45 UTC+1 schrieb Nicke:

CREATE TABLE users (
userid mediumint(8),
username varchar(255),
email varchar(255),
password varchar(255),
PRIMARY KEY (userid)
);

GET https://aaa.example.com/resolver/users
{
“jsonrpc”: “2.0”,
“signature”: “15622475369983…”,
“versionnumber”: “2.18.1”,
“version”: “privacyIDEA 2.18.1”,
“result”: {
“status”: true,
“value”: {
“users”: {
“type”: “sqlresolver”,
“data”: {
“Map”: “{“userid”: “userid”, “username”: “username”, “email”:
“email”, “password”: “password” }”,
“Encoding”: “”,
“Driver”: “mysql”,
“Database”: “users”,
“Editable”: “1”,
“Server”: “127.0.0.1”,
“Limit”: “500”,
“User”: “users”,
“poolTimeout”: “”,
“Table”: “users”,
“Password”: “ZyV2r1xxxxAO83d”,
“Port”: “3306”
},
“resolvername”: “users”
}
}
},
“time”: 1490270412.660811,
“id”: 1
}

POST https://aaa.example.com/user/

{
“jsonrpc”: “2.0”,
“signature”: “2518239733490006699…”,
“detail”: null,
“version”: “privacyIDEA 2.18.1”,
“result”: {
“status”: false,
“error”: {
“message”: “‘Session’ object has no attribute ‘_model_changes’”,
“code”: -500
}
},
“time”: 1490270564.568782,
“id”: 1
}

Den torsdag 23 mars 2017 kl. 12:08:51 UTC+1 skrev Nicke:

Am trying to add user or edit users in a “users” database located in
the same mysql server as privacyidea.
I have tried to add/edit user both within webgui and API which always
result in the error message
‘Session’ object has no attribute ‘_model_changes’"

[2017-03-23 11:58:28,091][3165][140013674645248][ERROR][privacyidea.app
:1423] Exception on /user/ [POST]
Traceback (most recent call last):
File “/usr/lib/python2.7/dist-packages/flask/app.py”, line 1817, in
wsgi_app
response = self.full_dispatch_request()
File “/usr/lib/python2.7/dist-packages/flask/app.py”, line 1477, in
full_dispatch_request
rv = self.handle_user_exception(e)
File “/usr/lib/python2.7/dist-packages/flask/app.py”, line 1381, in
handle_user_exception
reraise(exc_type, exc_value, tb)
File “/usr/lib/python2.7/dist-packages/flask/app.py”, line 1475, in
full_dispatch_request
rv = self.dispatch_request()
File “/usr/lib/python2.7/dist-packages/flask/app.py”, line 1461, in
dispatch_request
return self.view_functionsrule.endpoint
File
“/usr/lib/python2.7/dist-packages/privacyidea/api/lib/prepolicy.py”,
line 115, in policy_wrapper
return wrapped_function(*args, **kwds)
File “/usr/lib/python2.7/dist-packages/privacyidea/api/auth.py”,
line 313, in decorated_function
return f(*args, **kwargs)
File “/usr/lib/python2.7/dist-packages/privacyidea/api/user.py”,
line 173, in create_user_api
r = create_user(resolvername, attributes, password=password)
File “/usr/lib/python2.7/dist-packages/privacyidea/lib/log.py”, line
187, in log_wrapper
f_result = func(*args, **kwds)
File “/usr/lib/python2.7/dist-packages/privacyidea/lib/user.py”,
line 485, in create_user
uid = y.add_user(attributes)
File
“/usr/lib/python2.7/dist-packages/privacyidea/lib/resolvers/SQLIdResolver.py”
, line 709, in add_user
self.db.commit()
File “/usr/lib/python2.7/dist-packages/sqlsoup.py”, line 268, in
commit
self.session.commit()
File “/usr/lib/python2.7/dist-packages/sqlalchemy/orm/scoping.py”,
line 150, in do
return getattr(self.registry(), name)(*args, **kwargs)
File “/usr/lib/python2.7/dist-packages/sqlalchemy/orm/session.py”,
line 813, in commit
self.transaction.commit()
File “/usr/lib/python2.7/dist-packages/sqlalchemy/orm/session.py”,
line 392, in commit
self._prepare_impl()
File “/usr/lib/python2.7/dist-packages/sqlalchemy/orm/session.py”,
line 361, in _prepare_impl
self.session.dispatch.before_commit(self.session)
File “/usr/lib/python2.7/dist-packages/sqlalchemy/event/attr.py”,
line 218, in call
fn(*args, **kw)
File “/usr/lib/python2.7/dist-packages/flask_sqlalchemy/init.py”,
line 162, in session_signal_before_commit
d = session._model_changes
AttributeError: ‘Session’ object has no attribute ‘_model_changes’

Machine is a new Ubuntu server 16.04. Privacyidea installed today from
ubuntu repository, v1.18.1.

How do I troubleshoot this error message?

Dear cornelinux.
v2.19 still “‘Session’ object has no attribute ‘_model_changes’” when i add user (user file sqlite And user database mysql). But with ubuntu ppa-dev, it’s ok. How to i fix it? . Thank you.

Hi Tuan,

please provide more information:

Which ubuntu version? 14.04/16.04?

MySQL user in the same database as the token database, please elaborate on this.

ppa stable does not work?

ppa-dev does?

Please also provide your SQL Resolver config.

Thanks
Cornelius

Thank for response.
My os: Ubuntu 16.04, Privacy 2.19
-Part1 (sqlite-file): i use tool: https://github.com/privacyidea/privacyidea/blob/master/tools/privacyidea-create-userdb
to create user-resolver and realm.

Config-default:
====Resolver name: localusers
====Driver: sqlite
====Server: /
====Port:
====Database: /etc/privacyidea/users.sqlite
====User:
====Password:

When add user, Privacy notification : ‘Session’ object has no attribute ‘_model_changes’

-Part2 (mysql-db): i run command
pi-manage resolver create_internal myfirstresolver
pi-manage realm create myrealm myfirstresolver

My-Config:
Resolver name: myfirstresolver
Driver: mysql
Server: localhost Port:3306
Database: pi
User: pi
Password: ••••••••••••
Edit user store: Yes
Tables: users_myfirstresolver Limit: 5000

Another, i change user pi to user full permission edit on db. Still happen like that ( AttributeError: ‘Session’ object has no attribute ‘_model_changes’)

With ppa-dev. 2.19dev5 . I repeat part1/part2. Add user fine.

LOGS======================================================LOGS:
[2017-06-06 18:41:17,538][14218][140234568062720][INFO][privacyidea.lib.resolvers.SQLIdResolver:570] using the connect string sqlite://///etc/privacyidea/users.sqlite
[2017-06-06 18:41:17,568][14218][140234568062720][ERROR][privacyidea.app:1423] Exception on /user/ [POST]
Traceback (most recent call last):
File “/usr/lib/python2.7/dist-packages/flask/app.py”, line 1817, in wsgi_app
response = self.full_dispatch_request()
File “/usr/lib/python2.7/dist-packages/flask/app.py”, line 1477, in full_dispatch_request
rv = self.handle_user_exception(e)
File “/usr/lib/python2.7/dist-packages/flask/app.py”, line 1381, in handle_user_exception
reraise(exc_type, exc_value, tb)
File “/usr/lib/python2.7/dist-packages/flask/app.py”, line 1475, in full_dispatch_request
rv = self.dispatch_request()
File “/usr/lib/python2.7/dist-packages/flask/app.py”, line 1461, in dispatch_request
return self.view_functionsrule.endpoint
File “/usr/lib/python2.7/dist-packages/privacyidea/api/lib/prepolicy.py”, line 117, in policy_wrapper
return wrapped_function(*args, **kwds)
File “/usr/lib/python2.7/dist-packages/privacyidea/api/auth.py”, line 313, in decorated_function
return f(*args, **kwargs)
File “/usr/lib/python2.7/dist-packages/privacyidea/api/user.py”, line 173, in create_user_api
r = create_user(resolvername, attributes, password=password)
File “/usr/lib/python2.7/dist-packages/privacyidea/lib/log.py”, line 154, in log_wrapper
return func(*args, **kwds)
File “/usr/lib/python2.7/dist-packages/privacyidea/lib/user.py”, line 505, in create_user
uid = y.add_user(attributes)
File “/usr/lib/python2.7/dist-packages/privacyidea/lib/resolvers/SQLIdResolver.py”, line 710, in add_user
self.db.commit()
File “/usr/lib/python2.7/dist-packages/sqlsoup.py”, line 268, in commit
self.session.commit()
File “/usr/lib/python2.7/dist-packages/sqlalchemy/orm/scoping.py”, line 150, in do
return getattr(self.registry(), name)(*args, **kwargs)
File “/usr/lib/python2.7/dist-packages/sqlalchemy/orm/session.py”, line 813, in commit
self.transaction.commit()
File “/usr/lib/python2.7/dist-packages/sqlalchemy/orm/session.py”, line 392, in commit
self._prepare_impl()
File “/usr/lib/python2.7/dist-packages/sqlalchemy/orm/session.py”, line 361, in _prepare_impl
self.session.dispatch.before_commit(self.session)
File “/usr/lib/python2.7/dist-packages/sqlalchemy/event/attr.py”, line 218, in call
fn(*args, **kw)
File “/usr/lib/python2.7/dist-packages/flask_sqlalchemy/init.py”, line 162, in session_signal_before_commit
d = session._model_changes
AttributeError: ‘Session’ object has no attribute ‘_model_changes’

[2017-06-06 18:52:34,621][14218][140234568062720][INFO][privacyidea.lib.resolvers.PasswdIdResolver:130] loading users from file /etc/passwd from within ‘/home/privacyidea’
[2017-06-06 18:52:47,145][14218][140234568062720][INFO][privacyidea.lib.resolvers.SQLIdResolver:570] using the connect string mysql://pi:3Y52SdVt3Hgl@localhost/pi
[2017-06-06 18:52:47,387][14218][140234568062720][ERROR][privacyidea.app:1423] Exception on /user/ [POST]
Traceback (most recent call last):
File “/usr/lib/python2.7/dist-packages/flask/app.py”, line 1817, in wsgi_app
response = self.full_dispatch_request()
File “/usr/lib/python2.7/dist-packages/flask/app.py”, line 1477, in full_dispatch_request
rv = self.handle_user_exception(e)
File “/usr/lib/python2.7/dist-packages/flask/app.py”, line 1381, in handle_user_exception
reraise(exc_type, exc_value, tb)
File “/usr/lib/python2.7/dist-packages/flask/app.py”, line 1475, in full_dispatch_request
rv = self.dispatch_request()
File “/usr/lib/python2.7/dist-packages/flask/app.py”, line 1461, in dispatch_request
return self.view_functionsrule.endpoint
File “/usr/lib/python2.7/dist-packages/privacyidea/api/lib/prepolicy.py”, line 117, in policy_wrapper
return wrapped_function(*args, **kwds)
File “/usr/lib/python2.7/dist-packages/privacyidea/api/auth.py”, line 313, in decorated_function
return f(*args, **kwargs)
File “/usr/lib/python2.7/dist-packages/privacyidea/api/user.py”, line 173, in create_user_api
r = create_user(resolvername, attributes, password=password)
File “/usr/lib/python2.7/dist-packages/privacyidea/lib/log.py”, line 154, in log_wrapper
return func(*args, **kwds)
File “/usr/lib/python2.7/dist-packages/privacyidea/lib/user.py”, line 505, in create_user
uid = y.add_user(attributes)
File “/usr/lib/python2.7/dist-packages/privacyidea/lib/resolvers/SQLIdResolver.py”, line 710, in add_user
self.db.commit()
File “/usr/lib/python2.7/dist-packages/sqlsoup.py”, line 268, in commit
self.session.commit()
File “/usr/lib/python2.7/dist-packages/sqlalchemy/orm/scoping.py”, line 150, in do
return getattr(self.registry(), name)(*args, **kwargs)
File “/usr/lib/python2.7/dist-packages/sqlalchemy/orm/session.py”, line 813, in commit
self.transaction.commit()
File “/usr/lib/python2.7/dist-packages/sqlalchemy/orm/session.py”, line 392, in commit
self._prepare_impl()
File “/usr/lib/python2.7/dist-packages/sqlalchemy/orm/session.py”, line 361, in _prepare_impl
self.session.dispatch.before_commit(self.session)
File “/usr/lib/python2.7/dist-packages/sqlalchemy/event/attr.py”, line 218, in call
fn(*args, **kw)
File “/usr/lib/python2.7/dist-packages/flask_sqlalchemy/init.py”, line 162, in session_signal_before_commit
d = session._model_changes
AttributeError: ‘Session’ object has no attribute ‘_model_changes’

Thanks!.

I just did a search and found:


That looks like an incompatibility…

How did you install privacyidea? I have installed from ppa and have:

python-flask-sqlalchemy 2.0-1xenial1
python-sqlalchemy 1.0.11+ds1-1ubuntu2

But I don’t use SQL-Resolver, so it’s not easy for me to check.

Indeed it could be that the devs repo provides some different versions of the dependency packages. But I had no time to check, yet.
So @tuanduong122 please check as Jochen asked.

I install privacyIDEA by add ppa. https://privacyidea.readthedocs.io/en/latest/installation/ubuntu.html
dpkg --list | grep sqlalchemy
python-flask-sqlalchemy 1.0-3
python-sqlalchemy 1.0.11+ds1-1ubuntu2


After update python-flask-sqlalchemy from v1.0.3 to: 2.0-1xenial1 . Create user use SQLresolver normal - No problem

Thanks @Jochen_Hein and @cornelinux support. Thanks!

Cool! Thanks a lot for the feedback.