Пример #1
0
def post_data():
    title = request.form["plottitle"]
    type = request.form["plottype"]
    var_list = request.form["varlist"]
    var_type = json.loads(request.form["vartype"])
    # ensure var_type is a list
    if isinstance(var_type, basestring):
        var_type = [var_type]

    var_names = json.loads(request.form["varnames"])
    # ensure var_names is a list
    if isinstance(var_names, basestring):
        var_names = [var_names]

    d3params = request.form["d3Params"]

    obj = HealthVis(
        type=type, title=title, var_type=var_type, var_names=var_names, var_list=var_list, d3params=d3params
    )

    memcache_key = "hm_%d" % uuid4()
    try:
        res = memcache.set(key=memcache_key, value=obj)
    except:
        return "error"

    if res:
        return memcache_key

    try:
        obj.put()
    except:
        return "error"
    return "hs_%d" % obj.key().id()
Пример #2
0
def post_data():
    title = request.form['plottitle']
    type = request.form['plottype']
    var_list = request.form['varlist']
    var_type = json.loads(request.form['vartype'])
    var_names = json.loads(request.form['varnames'])
    d3params = request.form['d3Params']

    obj = HealthVis(type=type,
                    title=title,
                    var_type=var_type,
                    var_names=var_names,
                    var_list=var_list,
                    d3params=d3params)

    memcache_key='hm_%d' % uuid4()
    try:
        res=memcache.set(key=memcache_key, value=obj)
    except:
        return "error"

    if res:
        return memcache_key

    try:
        obj.put()
    except:
        return "error"
    return 'hs_%d' % obj.key().id()
Пример #3
0
def display(id):
    obj = HealthVis.get_by_id(id)
    if obj is None:
        return render_template("500.html")

    form = generate_form(obj)
    if obj.type not in supported_types:
        return render_template("500.html")

    return render_template("base.html", obj=obj, form=form)
Пример #4
0
def post_data():
    title = request.form['plottitle']
    type = request.form['plottype']
    var_list = request.form['varlist']
    var_type = json.loads(request.form['vartype'])
    var_names = json.loads(request.form['varnames'])
    d3params = request.form['d3Params']

    obj = HealthVis(type=type,
                    title=title,
                    var_type=var_type,
                    var_names=var_names,
                    var_list=var_list,
                    d3params=d3params)
    try:
        obj.put()
    except:
        return "error"
    return str(obj.key().id())
Пример #5
0
def display(id):
    obj = HealthVis.get_by_id(id)
    if obj is None:
        return render_template("500.html")

    form = generate_form(obj)
    if obj.type not in supported_types:
        return render_template("500.html")

    return render_template("base.html", obj=obj, form=form)
Пример #6
0
def post_data():
    title = request.form['plottitle']
    type = request.form['plottype']
    var_list = request.form['varlist']
    var_type = json.loads(request.form['vartype'])
    var_names = json.loads(request.form['varnames'])
    d3params = request.form['d3Params']

    obj = HealthVis(type=type,
                    title=title,
                    var_type=var_type,
                    var_names=var_names,
                    var_list=var_list,
                    d3params=d3params)
    try:
        obj.put()
    except:
        return "error"
    return str(obj.key().id())
Пример #7
0
def save(id):
    obj = HealthVis.get_by_id(id)
    if obj is None:
        return render_template("500.html")

    obj.saved = True
    try:
        obj.put()
    except:
        return render_template("500.html")
    return redirect(url_for('display', id=id))
Пример #8
0
def save(id):
    obj = HealthVis.get_by_id(id)
    if obj is None:
        return render_template("500.html")

    obj.saved = True
    try:
        obj.put()
    except:
        return render_template("500.html")
    return redirect(url_for('display', id=id))
Пример #9
0
def remove_unsaved():
    now = datetime.now()
    objs = HealthVis.all().filter("saved =", False)
    for obj in objs:
        if (obj.timestamp - now) < timedelta(hours=6):
            continue

        try:
            obj.delete()
        except:
            logging.info("Couldn't delete object " + str(obj))
            continue
Пример #10
0
def remove_unsaved():
    now = datetime.now()
    objs = HealthVis.all().filter("saved =", False)
    for obj in objs:
        if (obj.timestamp - now) < timedelta(hours=6):
            continue

        try:
            obj.delete()
        except:
            logging.info("Couldn't delete object " + str(obj))
            continue
Пример #11
0
def find_object(id):
    # parse id to see if the object is in memcache or datastore
    m = re.search(r"h(s|m)_(\d+)", id)
    if m is None:
        return None

    storeid = int(m.group(2))
    obj = None

    if m.group(1) == 's':
        # object stored in datastore
        obj = HealthVis.get_by_id(storeid)
    elif m.group(1) == 'm':
        # object in memcache
        obj = memcache.get(id)
    else:
        return None

    return obj
Пример #12
0
def find_object(plotid):
    # parse id to see if the object is in memcache or datastore
    m = re.search(r"h(s|m)_(\d+)", plotid)
    if m is None:
        return None

    storeid = int(m.group(2))
    obj = None

    if m.group(1) == "s":
        # object stored in datastore
        obj = HealthVis.get_by_id(storeid)
    elif m.group(1) == "m":
        # object in memcache
        obj = memcache.get(plotid)
    else:
        return None

    return obj
Пример #13
0
def get_params(id):
    obj = HealthVis.get_by_id(id)
    if obj is None:
        return render_template("500.html")
    return obj.d3params
Пример #14
0
def get_params(id):
    obj = HealthVis.get_by_id(id)
    if obj is None:
        return render_template("500.html")
    return obj.d3params