.oO SearXNG Developer Documentation Oo.
Loading...
Searching...
No Matches
searx.preferences.SetSetting Class Reference
+ Inheritance diagram for searx.preferences.SetSetting:
+ Collaboration diagram for searx.preferences.SetSetting:

Public Member Functions

 __init__ (self, *args, **kwargs)
 
 get_value (self)
 
 parse (self, str data)
 
 parse_form (self, str data)
 
 save (self, str name, flask.Response resp)
 
- Public Member Functions inherited from searx.preferences.Setting

Public Attributes

 values = set()
 
 locked
 
- Public Attributes inherited from searx.preferences.Setting
 value = default_value
 
 locked = locked
 

Detailed Description

Setting of values of type ``set`` (comma separated string)

Definition at line 132 of file preferences.py.

Constructor & Destructor Documentation

◆ __init__()

searx.preferences.SetSetting.__init__ ( self,
* args,
** kwargs )

Reimplemented from searx.preferences.Setting.

Definition at line 135 of file preferences.py.

135 def __init__(self, *args, **kwargs):
136 super().__init__(*args, **kwargs)
137 self.values = set()
138

References searx.preferences.SetSetting.__init__().

Referenced by searx.preferences.SetSetting.__init__().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Function Documentation

◆ get_value()

searx.preferences.SetSetting.get_value ( self)
Returns a string with comma separated values.

Reimplemented from searx.preferences.Setting.

Definition at line 139 of file preferences.py.

139 def get_value(self):
140 """Returns a string with comma separated values."""
141 return ','.join(self.values)
142

References searx.preferences.SetSetting.values.

◆ parse()

searx.preferences.SetSetting.parse ( self,
str data )
Parse and validate ``data`` and store the result at ``self.value``

Reimplemented from searx.preferences.Setting.

Definition at line 143 of file preferences.py.

143 def parse(self, data: str):
144 """Parse and validate ``data`` and store the result at ``self.value``"""
145 if data == '':
146 self.values = set()
147 return
148
149 elements = data.split(',')
150 for element in elements:
151 self.values.add(element)
152

References searx.preferences.SetSetting.values.

◆ parse_form()

searx.preferences.SetSetting.parse_form ( self,
str data )

Definition at line 153 of file preferences.py.

153 def parse_form(self, data: str):
154 if self.locked:
155 return
156
157 elements = data.split(',')
158 self.values = set(elements)
159

◆ save()

searx.preferences.SetSetting.save ( self,
str name,
flask.Response resp )
Save cookie ``name`` in the HTTP response object

Reimplemented from searx.preferences.Setting.

Definition at line 160 of file preferences.py.

160 def save(self, name: str, resp: flask.Response):
161 """Save cookie ``name`` in the HTTP response object"""
162 resp.set_cookie(name, ','.join(self.values), max_age=COOKIE_MAX_AGE)
163
164

References searx.preferences.SetSetting.values.

Member Data Documentation

◆ locked

searx.preferences.SetSetting.locked

Definition at line 154 of file preferences.py.

Referenced by searx.preferences.BooleanChoices.parse_form().

◆ values

searx.preferences.SetSetting.values = set()

The documentation for this class was generated from the following file: