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

Public Member Functions

 normalized_str (self, val)
 
 parse (self, str data)
 
 save (self, str name, flask.Response resp)
 
- Public Member Functions inherited from searx.preferences.Setting
 __init__ (self, default_value, bool locked=False)
 
 get_value (self)
 

Public Attributes

 value = MAP_STR2BOOL[data]
 
 key = self.normalized_str(self.value)
 
- Public Attributes inherited from searx.preferences.Setting
 value = default_value
 
 locked = locked
 

Detailed Description

Setting of a boolean value that has to be translated in order to be storable

Definition at line 213 of file preferences.py.

Member Function Documentation

◆ normalized_str()

searx.preferences.BooleanSetting.normalized_str ( self,
val )

Definition at line 216 of file preferences.py.

216 def normalized_str(self, val):
217 for v_str, v_obj in MAP_STR2BOOL.items():
218 if val == v_obj:
219 return v_str
220 raise ValueError("Invalid value: %s (%s) is not a boolean!" % (repr(val), type(val)))
221

◆ parse()

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

Reimplemented from searx.preferences.Setting.

Definition at line 222 of file preferences.py.

222 def parse(self, data: str):
223 """Parse and validate ``data`` and store the result at ``self.value``"""
224 self.value = MAP_STR2BOOL[data]
225 self.key = self.normalized_str(self.value) # pylint: disable=attribute-defined-outside-init
226

◆ save()

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

Reimplemented from searx.preferences.Setting.

Definition at line 227 of file preferences.py.

227 def save(self, name: str, resp: flask.Response):
228 """Save cookie ``name`` in the HTTP response object"""
229 if hasattr(self, 'key'):
230 resp.set_cookie(name, self.key, max_age=COOKIE_MAX_AGE)
231
232

References searx.preferences.BooleanSetting.key, and searx.preferences.MapSetting.key.

Member Data Documentation

◆ key

searx.preferences.BooleanSetting.key = self.normalized_str(self.value)

◆ value


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