aboutsummaryrefslogtreecommitdiff
path: root/wqflask
diff options
context:
space:
mode:
authorPjotr Prins2018-04-04 16:58:21 +0000
committerPjotr Prins2018-04-04 16:58:21 +0000
commit8145507d6d617554cf996e6cebf286d30ae64df0 (patch)
treefd820ef8bf1ca24dd312555c4d1e2eac6f9f112e /wqflask
parent04280c8e1197384e426fe5b19230168f39e5ae94 (diff)
downloadgenenetwork2-8145507d6d617554cf996e6cebf286d30ae64df0.tar.gz
ES: doc
Diffstat (limited to 'wqflask')
-rw-r--r--wqflask/utility/elasticsearch_tools.py9
-rw-r--r--wqflask/wqflask/user_manager.py23
2 files changed, 9 insertions, 23 deletions
diff --git a/wqflask/utility/elasticsearch_tools.py b/wqflask/utility/elasticsearch_tools.py
index 734379f7..1dba357d 100644
--- a/wqflask/utility/elasticsearch_tools.py
+++ b/wqflask/utility/elasticsearch_tools.py
@@ -12,6 +12,7 @@ def test_elasticsearch_connection():
logger.warning("Elasticsearch is DOWN")
def get_elasticsearch_connection():
+ """Return a connection to ES. Returns None on failure"""
logger.info("get_elasticsearch_connection")
es = None
try:
@@ -20,14 +21,14 @@ def get_elasticsearch_connection():
logger.info("ES HOST",ELASTICSEARCH_HOST)
es = Elasticsearch([{
- "host": ELASTICSEARCH_HOST
- , "port": ELASTICSEARCH_PORT
+ "host": ELASTICSEARCH_HOST, "port": ELASTICSEARCH_PORT
}]) if (ELASTICSEARCH_HOST and ELASTICSEARCH_PORT) else None
es_logger = logging.getLogger("elasticsearch")
es_logger.setLevel(logging.INFO)
es_logger.addHandler(logging.NullHandler())
except:
+ logger.error("Failed to get elasticsearch connection")
es = None
return es
@@ -42,9 +43,7 @@ def get_item_by_unique_column(es, column_name, column_value, index, doc_type):
item_details = None
try:
response = es.search(
- index = index
- , doc_type = doc_type
- , body = {
+ index = index, doc_type = doc_type, body = {
"query": { "match": { column_name: column_value } }
})
if len(response["hits"]["hits"]) > 0:
diff --git a/wqflask/wqflask/user_manager.py b/wqflask/wqflask/user_manager.py
index ac3824a7..ead919fc 100644
--- a/wqflask/wqflask/user_manager.py
+++ b/wqflask/wqflask/user_manager.py
@@ -1,45 +1,30 @@
from __future__ import print_function, division, absolute_import
-"""Used to Access things in template like this:
-(BUT NOW OUT OF DATE)
-
- x: {{ g.identity.name }}
- security: {{ security.__dict__ }}
-
-"""
-
import os
import hashlib
import datetime
import time
import logging
-
import uuid
import hashlib
import hmac
import base64
-
import urlparse
import simplejson as json
#from redis import StrictRedis
-import redis
+import redis # used for collections
Redis = redis.StrictRedis()
-
from flask import (Flask, g, render_template, url_for, request, make_response,
redirect, flash, abort)
from wqflask import app
-
-
from pprint import pformat as pf
-from wqflask import pbkdf2
-
+from wqflask import pbkdf2 # password hashing
from wqflask.database import db_session
-
from wqflask import model
from utility import Bunch, Struct, after
@@ -62,8 +47,8 @@ THREE_DAYS = 60 * 60 * 24 * 3
def timestamp():
return datetime.datetime.utcnow().isoformat()
-
class AnonUser(object):
+ """Anonymous user handling"""
cookie_name = 'anon_user_v8'
def __init__(self):
@@ -169,6 +154,8 @@ def create_signed_cookie():
return the_uuid, uuid_signed
class UserSession(object):
+ """Logged in user handling"""
+
cookie_name = 'session_id_v2'
def __init__(self):