about summary refs log tree commit diff
path: root/nixpkgs/pkgs/tools/admin/pgadmin/expose-setup.py.patch
blob: ac68eabd411d605e33006efe104be21a9661028f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
 pkg/pip/setup_pip.py |  5 ++++-
 web/setup.py         | 14 ++++++++------
 2 files changed, 12 insertions(+), 7 deletions(-)

diff --git a/pkg/pip/setup_pip.py b/pkg/pip/setup_pip.py
index 5592d1b04..131eaa1ed 100644
--- a/pkg/pip/setup_pip.py
+++ b/pkg/pip/setup_pip.py
@@ -95,7 +95,10 @@ setup(
     },
 
     entry_points={
-        'console_scripts': ['pgadmin4=pgadmin4.pgAdmin4:main'],
+        'console_scripts': [
+            'pgadmin4=pgadmin4.pgAdmin4:main',
+            'pgadmin4-setup=pgadmin4.setup:main'
+        ],
     },
 
 )
diff --git a/web/setup.py b/web/setup.py
index 2204ffb..d5fda9f 100644
--- a/web/setup.py
+++ b/web/setup.py
@@ -14,7 +14,6 @@ import argparse
 import os
 import sys
 import builtins
-import config

 # Grab the SERVER_MODE if it's been set by the runtime
 if 'SERVER_MODE' in globals():
@@ -91,6 +90,9 @@ def load_servers(args):
 def setup_db(app):
     """Setup the configuration database."""

+    # here we need an additional import, since the call to setup_db changed
+    # https://redmine.postgresql.org/projects/pgadmin4/repository/2/revisions/3a69d50458f57d19948b867aec55c55d635a36e5/diff/web/setup.py
+    import config
     create_app_data_directory(config)

     print("pgAdmin 4 - Application Initialisation")
@@ -139,8 +141,9 @@ def clear_servers():
         clear_database_servers(load_user, True)


-if __name__ == '__main__':
+def main():
     # Configuration settings
+    import config
     parser = argparse.ArgumentParser(description='Setup the pgAdmin config DB')

     exp_group = parser.add_argument_group('Dump server config')
@@ -191,3 +194,6 @@ if __name__ == '__main__':
     else:
         app = create_app()
         setup_db(app)
+
+if __name__ == '__main__':
+    main()

diff --git a/web/pgadmin/model/__init__.py b/web/pgadmin/model/__init__.py
index 4c36dd1..a492365 100644
--- a/web/pgadmin/model/__init__.py
+++ b/web/pgadmin/model/__init__.py
@@ -23,7 +23,6 @@ from flask_sqlalchemy import SQLAlchemy
 from sqlalchemy.ext.mutable import MutableDict
 import sqlalchemy.types as types
 import uuid
-import config

 ##########################################################################
 #
@@ -41,10 +40,12 @@ SCHEMA_VERSION = 35
 #
 ##########################################################################

+# hardcode poolsize and max_overflow due to a circular import (config imports model,
+# model now tries to import config)
 db = SQLAlchemy(
     engine_options={
-        'pool_size': config.CONFIG_DATABASE_CONNECTION_POOL_SIZE,
-        'max_overflow': config.CONFIG_DATABASE_CONNECTION_MAX_OVERFLOW})
+        'pool_size': 5,
+        'max_overflow': 100})


 USER_ID = 'user.id'