MCPcopy Index your code
hub / github.com/pgadmin-org/pgadmin4 / get

Method get

web/pgadmin/utils/preferences.py:99–136  ·  view source on GitHub ↗

get Fetch the value from the server for the current user from the configuration table (if available), otherwise returns the default value for it. :returns: value for this preference.

(self)

Source from the content-addressed store, hash-verified

97 self.pid = res.id
98
99 def get(self):
100 """
101 get
102 Fetch the value from the server for the current user from the
103 configuration table (if available), otherwise returns the default value
104 for it.
105
106 :returns: value for this preference.
107 """
108 res = UserPrefTable.query.filter_by(
109 pid=self.pid
110 ).filter_by(uid=current_user.id).first()
111
112 # Could not find any preference for this user, return default value.
113 if res is None:
114 return self.default
115
116 # The data stored in the configuration will be in string format, we
117 # need to convert them in proper format.
118 is_format_data, data = self._get_format_data(res)
119 if is_format_data:
120 return data
121
122 if self._type == 'text' and res.value == '' and not self.allow_blanks:
123 return self.default
124
125 parser_map = {
126 'integer': int,
127 'numeric': decimal.Decimal,
128 'date': dateutil_parser.parse,
129 'datetime': dateutil_parser.parse,
130 'keyboardshortcut': json.loads
131 }
132 try:
133 return parser_map.get(self._type, lambda v: v)(res.value)
134 except Exception as e:
135 current_app.logger.exception(e)
136 return self.default
137
138 def _get_format_data(self, res):
139 """

Callers 6

to_jsonMethod · 0.95
__init__Method · 0.45
setMethod · 0.45
registerMethod · 0.45
register_preferenceMethod · 0.45
save_cliMethod · 0.45

Calls 2

_get_format_dataMethod · 0.95
firstMethod · 0.65

Tested by

no test coverage detected