Hi,

When you try to run pgadmin4 for first time(without presence of pgadmin4.db), 
it ask you to run setup.py. When you run it, it throws python error as follows,
Traceback (most recent call last):
  File "/home/test/Development/pgadmin4/web/setup.py", line 145, in <module>
    do_setup(app)
  File "/home/test/Development/pgadmin4/web/setup.py", line 57, in do_setup
    user_datastore.add_role_to_user(email, 'Administrators')
  File 
"/usr/local/lib/python2.7/dist-packages/Flask_Security-1.7.4-py2.7.egg/flask_security/datastore.py",
 line 106, in add_role_to_user
    if role not in user.roles:
AttributeError: 'NoneType' object has no attribute 'roles'

It's because,user_datastore.create_role,user_datastore.create_user and 
user_datastore.add_role_to_user all calls are for in one database transaction. 
It need to commit it after first two calls or creating role and user for 
add_role_to_user to work,

Find attached patch for this.

regards,
Prasad Somwanshi
diff --git a/web/setup.py b/web/setup.py
index 0550862..067c753 100644
--- a/web/setup.py
+++ b/web/setup.py
@@ -54,6 +54,7 @@ def do_setup(app):
         db.create_all()
         user_datastore.create_role(name='Administrators', description='pgAdmin Administrators Role')
         user_datastore.create_user(email=email, password=password)
+        db.session.commit()
         user_datastore.add_role_to_user(email, 'Administrators')
 
         # Get the user's ID and create the default server group
-- 
Sent via pgadmin-hackers mailing list (pgadmin-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgadmin-hackers

Reply via email to