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

Class Preferences

web/pgadmin/utils/preferences.py:277–740  ·  view source on GitHub ↗

class Preferences It helps to manage all the preferences/options related to a specific module. It keeps track of all the preferences registered with it using this class in the group of categories. Also, create the required entries for each module, and categories in the

Source from the content-addressed store, hash-verified

275
276
277class Preferences():
278 """
279 class Preferences
280
281 It helps to manage all the preferences/options related to a specific
282 module.
283
284 It keeps track of all the preferences registered with it using this class
285 in the group of categories.
286
287 Also, create the required entries for each module, and categories in the
288 preferences tables (if required). If it is already present, it will refer
289 to the existing data from those tables.
290
291 class variables:
292 ---------------
293 modules:
294 Dictionary of all the modules, can be refered by its name.
295 Keeps track of all the modules in it, so that - only one object per module
296 gets created. If the same module refered by different object, the
297 categories dictionary within it will be shared between them to keep the
298 consistent data among all the object.
299
300 Instance Definitions:
301 -------- -----------
302 """
303 modules = dict()
304
305 def __init__(self, name, label=None):
306 """
307 __init__
308 Constructor/Initializer for the Preferences class.
309
310 :param name: Name of the module
311 :param label: Display name of the module, it will be displayed in the
312 preferences.
313
314 :returns nothing
315 """
316 self.name = name
317 self.label = label
318 self.categories = dict()
319
320 # Find the entry for this module in the configuration database.
321 module = ModulePrefTable.query.filter_by(name=name).first()
322
323 # Can't find the reference for it in the configuration database,
324 # create on for it.
325 if module is None:
326 module = ModulePrefTable(name=name)
327 db.session.add(module)
328 db.session.commit()
329 module = ModulePrefTable.query.filter_by(name=name).first()
330
331 self.mid = module.id
332
333 if name in Preferences.modules:
334 m = Preferences.modules[name]

Callers 8

register_preferencesMethod · 0.90
register_preferencesMethod · 0.90
register_preferencesMethod · 0.90
register_preferencesMethod · 0.90
register_preferenceMethod · 0.70
moduleMethod · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected