summaryrefslogtreecommitdiff
path: root/searx/search.py
diff options
context:
space:
mode:
authorNoemi Vanyi <sitbackandwait@gmail.com>2016-04-08 16:38:05 +0200
committerNoemi Vanyi <sitbackandwait@gmail.com>2016-04-09 01:08:44 +0200
commitfe691a09888f6e6c6cc647de06f4eca0feb3451f (patch)
treeb0e554726757290f8eff4bd44541c84dee38479d /searx/search.py
parent9331fc28a8ac2f898a437d126ee59353f7f1bfde (diff)
downloadsearxng-fe691a09888f6e6c6cc647de06f4eca0feb3451f.tar.gz
searxng-fe691a09888f6e6c6cc647de06f4eca0feb3451f.zip
new preferences handling
Preferences class was introduced in order to handle user preferences. Right now it parses cookies and the form in preferences. Also it can retrieve settings based on the name of the setting. ATTENTION Please note that engine preferences are handled differently from now on. So it introduces incompatible changes. Every user who has saved preferences should reset and save his/her settings again. This change was needed, because everytime a default disabled engine was added saved user preferences would broke. Now engine setting tracking is fixed.
Diffstat (limited to 'searx/search.py')
-rw-r--r--searx/search.py15
1 files changed, 5 insertions, 10 deletions
diff --git a/searx/search.py b/searx/search.py
index ce41b231b..f38d40106 100644
--- a/searx/search.py
+++ b/searx/search.py
@@ -23,7 +23,7 @@ from searx.engines import (
categories, engines
)
from searx.languages import language_codes
-from searx.utils import gen_useragent, get_blocked_engines
+from searx.utils import gen_useragent
from searx.query import Query
from searx.results import ResultContainer
from searx import logger
@@ -140,15 +140,13 @@ class Search(object):
self.lang = 'all'
# set blocked engines
- self.blocked_engines = get_blocked_engines(engines, request.cookies)
+ self.blocked_engines = request.preferences.engines.get_disabled()
self.result_container = ResultContainer()
self.request_data = {}
# set specific language if set
- if request.cookies.get('language')\
- and request.cookies['language'] in (x[0] for x in language_codes):
- self.lang = request.cookies['language']
+ self.lang = request.preferences.get_value('language')
# set request method
if request.method == 'POST':
@@ -294,11 +292,8 @@ class Search(object):
else:
request_params['language'] = self.lang
- try:
- # 0 = None, 1 = Moderate, 2 = Strict
- request_params['safesearch'] = int(request.cookies.get('safesearch'))
- except Exception:
- request_params['safesearch'] = settings['search']['safe_search']
+ # 0 = None, 1 = Moderate, 2 = Strict
+ request_params['safesearch'] = request.preferences.get_value('safesearch')
# update request parameters dependent on
# search-engine (contained in engines folder)