def deleteentry(): if request.method == "POST": counter = request.form["id"] model.delete_entry(counter) else: model.get_entries() return redirect("/admin")
def GET(self): '''show info''' entries = model.get_entries() if isactived_resource(): status = True else: status = False entries = model.get_entries() return render_ori.index(entries, status)
class opsapi: def GET(self): ''' This func is used to return server configurations from db ''' try: data = web.input() except AttributeError, e: return None if data.getinfo == 'all': rst = model.get_allentries() elif data.getinfo == 'vhost': rst = model.get_entries(type='vhost') elif data.getinfo == 'host': rst = model.get_entries(type='host') else: return None return render_ori.rawdata(rst,None)
def quick_search(keyword, CASEIGNORE=True): ''' This fuction is used to fetch id number with keyword''' ids = [] if CASEIGNORE: kw = ignore_rec(keyword) else: kw = re.compile(keyword) data = model.get_entries() for i in data: for item in i.itervalues(): item = str(item) result = re.search(kw, item) if result: if i.id not in ids: ids.append(i.id) #list(set(ids)) # simple way to uniq elments in the id list. return ids
def advance_search(kw, mode=0): # Advance mode for filtering record ''' mode = 0 means exact matching , keyword must exact match in the string mode = 1 means Ambiguous , just only matched the string will be returned. mode = 2 means Invert-matching. ''' ids = [] data = model.get_entries() for i in data: # Load data and convert into string. string = " ".join([str(item) for item in i.itervalues()]) # Print string for k in kw.keys(): kw[k] = _filter(k, string) if mode == 0: # Exact matching if False in kw.values(): #print kw,i.hostname continue else: #if i.id not in ids: # print i.hostname # print kw,i.hostname ids.append(i.id) elif mode == 1: # Ambiguous matching if True in kw.values(): ids.append(i.id) elif mode == 2: # Invert matching if False in kw.values(): ids.append(i.id) return ids
def view(): return render_template("view.html", entries=model.get_entries(), title=model.get_title())
def GET(self): entries = model.get_entries() status = isactived_resource() return render.index(entries, status)
def search_restaurant(): return render_template('search.html', entries=model.get_entries())
def editentry(): i = request.form["id"] return render_template("edit.html", id=i, entries=model.get_entries() )
def admin(): return render_template("admin.html", entries=model.get_entries())
def delete(): delete_id = request.form["id"] model.delete_entry(delete_id) return render_template("admin.html", entries=model.get_entries())
def index(): ## print the guestbook return render_template( "admin.html", entries=model.get_entries()) #new template "admin.html"--hw14 part1
def admin(): #model.delete_instance() return render_template("admin.html", entries=model.get_entries())
def GET(self): web.header('Content-type', 'text/json') d = model.get_entries() return json.dumps(d)
def admin(): ## print the guestbook return render_template("admin.html", entries=model.get_entries())
def admin(): # print("hello") return render_template("admin.html", entries=model.get_entries())
def admin(): model.init() ## add a guestbook entry return render_template("admin.html", entries=model.get_entries())
def index(): return render_template("index.html", entries=model.get_entries())
def administrator(): ## edit posts return render_template("admin.html", entries=model.get_entries())
def postentry(): name = request.form["name"] message = request.form["message"] model.add_entry(name, message) return render_template("admin.html", entries=model.get_entries())
def index(): ## print the guestbook return render_template("index.html", entries=model.get_entries())
def admin(): ## print the guestbook and allow for the admin to delete entries return render_template("admin.html", entries=model.get_entries())