Beispiel #1
0
 def GET(self, id=None):
     '''return form by user ID to edit. #render_ori.save_entry(id,form'''
     entry = model.get_entry(int(id))
     try:
         _type = entry.type
     except Exception, e:
         print "DB ERROR,%s", e
         return None
Beispiel #2
0
class Search:
    def GET(self):
        if isactived():
            status = True
        else:
            status = False
        data = web.input()
        keyword = data.search_body

        try:
            keyword = keyword.replace(unsupportchar, " ")
        except Exception, e:
            print "%s, exception occured." % e
            return None

        if keyword.find("+") != -1:
            "Advance search mode "
            keyword = change_into_dict(keyword.split("+"))
            # print keyword
            ids = advance_search(keyword)

        elif keyword.find(",") != -1 or keyword.find(" ") != -1:
            # Convert "," into whitespace
            keyword = change_into_dict(re.split("[ |,]", keyword))
            ids = advance_search(keyword, mode=1)

        elif keyword.find("!") != -1:
            # Invert matching
            keyword = change_into_dict(keyword.split("!"))
            ids = advance_search(keyword, mode=2)

        else:
            ids = quick_search(keyword)

        if isinstance(ids, list):
            search_results = []
            for id in ids:
                search_results.append(model.get_entry(id))
            return render.search(search_results, status)
Beispiel #3
0
def edit_entry(collection, id):
    # Obtener datos de la entrada desde la BD
    data = model.get_entry(collection, id)
    return render_template('edit_form.html', collection=collection, data=data)
Beispiel #4
0
def confirm_deletion(collection, id):
    data = model.get_entry(collection, id)
    return render_template('confirm_deletion.html',
                           collection=collection,
                           entry=data)
def changeentry():
    id_ = request.form["id"]
    entry = model.get_entry(id_)
    name = entry['author']
    return render_template("changeentry.html", name=name)
Beispiel #6
0
 def GET(self):
     web.header('Content-type', 'text/json') 
     d = model.get_entry()
     return json.dumps(dict(temp=d.temp, humidity= d.humidity, time=d.time))