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

Class _Preference

web/pgadmin/utils/preferences.py:28–274  ·  view source on GitHub ↗

Internal class representing module, and categoy bound preference.

Source from the content-addressed store, hash-verified

26
27
28class _Preference():
29 """
30 Internal class representing module, and categoy bound preference.
31 """
32
33 def __init__(
34 self, cid, name, label, _type, default, **kwargs
35 ):
36 """
37 __init__
38 Constructor/Initializer for the internal _Preference object.
39
40 It creates a new entry for this preference in configuration table based
41 on the name (if not exists), and keep the id of it for on demand value
42 fetching from the configuration table in later stage. Also, keeps track
43 of type of the preference/option, and other supporting parameters like
44 min, max, options, etc.
45
46 :param cid: configuration id
47 :param name: Name of the preference (must be unique for each
48 configuration)
49 :param label: Display name of the options/preference
50 :param _type: Type for proper validation on value
51 :param default: Default value
52 :param help_str: Help string to be shown in preferences.
53 :param min_val: minimum value
54 :param max_val: maximum value
55 :param options: options (Array of list objects)
56 :param select: select options (object)
57 :param fields: field schema (if preference has more than one field to
58 take input from user e.g. keyboardshortcut preference)
59 :param allow_blanks: Flag specify whether to allow blank value.
60
61 :returns: nothing
62 """
63 self.cid = cid
64 self.name = name
65 self.default = default
66 self.label = label
67 self._type = _type
68 self.help_str = kwargs.get('help_str', None)
69 self.control_props = kwargs.get('control_props', None)
70 self.min_val = kwargs.get('min_val', None)
71 self.max_val = kwargs.get('max_val', None)
72 self.options = kwargs.get('options', None)
73 self.select = kwargs.get('select', None)
74 self.fields = kwargs.get('fields', None)
75 self.hidden = kwargs.get('hidden', None)
76 self.allow_blanks = kwargs.get('allow_blanks', None)
77 self.disabled = kwargs.get('disabled', False)
78 self.dependents = kwargs.get('dependents', None)
79
80 # Look into the configuration table to find out the id of the specific
81 # preference.
82 res = PrefTable.query.filter_by(
83 name=name, cid=cid
84 ).first()
85

Callers 1

registerMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected