MCPcopy Create free account
hub / github.com/pgadmin-org/pgadmin4 / preferences

Function preferences

web/pgadmin/preferences/__init__.py:75–108  ·  view source on GitHub ↗

Fetch all/or requested preferences of pgAdmin IV.

(module=None, preference=None)

Source from the content-addressed store, hash-verified

73@blueprint.route("/<module>/<preference>", endpoint='get_by_name')
74@pga_login_required
75def preferences(module=None, preference=None):
76 """Fetch all/or requested preferences of pgAdmin IV."""
77
78 if module is not None and preference is not None:
79 try:
80 m = Preferences.module(module, create=False)
81 if m is None:
82 return Response(status=404)
83
84 p = m.preference(preference)
85 if p is None:
86 return Response(status=404)
87
88 return ajax_response(
89 response=p.to_json(),
90 status=200
91 )
92
93 except Exception as e:
94 return internal_server_error(errormsg=str(e))
95
96 # Load Preferences
97 pref = Preferences.preferences()
98 res = []
99
100 def label(p):
101 return gettext(p['label'])
102
103 _group_pref_by_categories(pref, res, label)
104
105 return ajax_response(
106 response=sorted(res, key=label),
107 status=200
108 )
109
110
111def _group_pref_by_categories(pref, res, label):

Callers 1

get_debugger_titleFunction · 0.90

Calls 6

internal_server_errorFunction · 0.90
moduleMethod · 0.80
preferenceMethod · 0.80
preferencesMethod · 0.80
to_jsonMethod · 0.45

Tested by

no test coverage detected