def names(environ, start_response): start_response('200 OK', [('Content-Type', 'text/html')]) name = environ['PATH_INFO'] rec = db.names.select("page='%s'" % name) template = lookup.get_template('names.html') if rec: rec = rec[0] ndisp = rec.display + 1 rec.set({'display': ndisp}) rec.save() #We defere the commit and allow the combine #defer(<python call back>, <argumtent>, <combined them>) #The argument is unique and mandatory. #If combined is True, then Fapws will add it in the queue if it's not yet present. evwsgi.defer(commit, None, True) #commit(True) return [ template.render(**{ "name": rec.name, "text": rec.text, "display": ndisp }) ] else: return ["Name not found"]
def application(environ, start_response): response_headers = [('Content-type', 'text/plain')] start_response('200 OK', response_headers) print "before defer", time.time() evwsgi.defer(toto, 0.2, False) #evwsgi.defer(toto, 1, True) print "after defer", time.time() return ["hello word!!"]
def disppage(environ, start_response): start_response('200 OK', [('Content-Type','text/html')]) #print environ page=environ['PATH_INFO'] rec=db.pages.get({'page':page}) template=lookup.get_template('page.html') if rec: ndisp=rec.display+1 rec.set({'display':ndisp}) rec.save() #con.commit() evwsgi.defer(commit,None, True) return [template.render(**{"page":rec.page,"text":rec.text,"display":ndisp})] else: return["Page not found"]
def names(environ, start_response): start_response('200 OK', [('Content-Type','text/html')]) name=environ['PATH_INFO'] rec=db.names.select("page='%s'" % name) template=lookup.get_template('names.html') if rec: rec=rec[0] ndisp=rec.display+1 rec.set({'display':ndisp}) rec.save() #We defere the commit and allow the combine #defer(<python call back>, <argumtent>, <combined them>) #The argument is unique and mandatory. #If combined is True, then Fapws will add it in the queue if it's not yet present. evwsgi.defer(commit, None, True) #commit(True) return [template.render(**{"name":rec.name,"text":rec.text,"display":ndisp})] else: return["Name not found"]