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

Public Member Functions

 __init__ (self, default_value, Dict[str, object] map, locked=False)
 
 parse (self, str data)
 
 save (self, str name, flask.Response resp)
 
- Public Member Functions inherited from searx.preferences.Setting
 get_value (self)
 

Public Attributes

 map = map
 
 value = self.map[data]
 
 key = data
 
- Public Attributes inherited from searx.preferences.Setting
 value = default_value
 
 locked = locked
 

Detailed Description

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

Definition at line 189 of file preferences.py.

Constructor & Destructor Documentation

◆ __init__()

searx.preferences.MapSetting.__init__ ( self,
default_value,
Dict[str, object] map,
locked = False )

Reimplemented from searx.preferences.Setting.

Definition at line 192 of file preferences.py.

192 def __init__(self, default_value, map: Dict[str, object], locked=False): # pylint: disable=redefined-builtin
193 super().__init__(default_value, locked)
194 self.map = map
195
196 if self.value not in self.map.values():
197 raise ValidationException('Invalid default value')
198

References searx.preferences.MapSetting.__init__().

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

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

Member Function Documentation

◆ parse()

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

Reimplemented from searx.preferences.Setting.

Definition at line 199 of file preferences.py.

199 def parse(self, data: str):
200 """Parse and validate ``data`` and store the result at ``self.value``"""
201
202 if data not in self.map:
203 raise ValidationException('Invalid choice: {0}'.format(data))
204 self.value = self.map[data]
205 self.key = data # pylint: disable=attribute-defined-outside-init
206

References searx.format, and searx.preferences.MapSetting.map.

◆ save()

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

Reimplemented from searx.preferences.Setting.

Definition at line 207 of file preferences.py.

207 def save(self, name: str, resp: flask.Response):
208 """Save cookie ``name`` in the HTTP response object"""
209 if hasattr(self, 'key'):
210 resp.set_cookie(name, self.key, max_age=COOKIE_MAX_AGE)
211
212

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

Member Data Documentation

◆ key

searx.preferences.MapSetting.key = data

◆ map

searx.preferences.MapSetting.map = map

Definition at line 194 of file preferences.py.

Referenced by searx.preferences.MapSetting.parse().

◆ value


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