Ejemplo n.º 1
0
def start_server():
    evwsgi.start("0.0.0.0", "5747")
    evwsgi.set_base_module(fapws.base)
    stats_app = AnyStat()
    evwsgi.wsgi_cb(("/stats/", stats_app))
    commit = lambda: stats_app.cache.commit()
    evwsgi.add_timer(10, commit)
    #evwsgi.set_debug(1)
    evwsgi.run()
Ejemplo n.º 2
0
        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 qsize():
    print "defer queue size:", evwsgi.defer_queue_size()


evwsgi.start("0.0.0.0", "8080")
evwsgi.set_base_module(base)
evwsgi.wsgi_cb(("/names/", names))
evwsgi.add_timer(2, qsize)
evwsgi.set_debug(0)
evwsgi.run()

con.close()
Ejemplo n.º 3
0
evwsgi.set_base_module(base)
    
def names(environ, start_response):
    start_response('200 OK', [('Content-Type','text/html')])
    name=environ['PATH_INFO']
    rec=db.names.select("name='%s'" % name)
    template=lookup.get_template('names.html')
    if rec:
        rec=rec[0]
        ndisp=rec.display+1
        rec.set({'display':ndisp})
        rec.save()
        #uncomment the following to force a commit for each request
        #db.names.commit()
        return [template.render(**{"name":rec.name,"text":rec.text,"display":ndisp})]
    else:
        return["Name not found"]

def commit():
    con.commit()
    print "commit"

    
#he following trigger a commit every 2 seconds    
evwsgi.add_timer(2,commit)
evwsgi.wsgi_cb(("/names/", names))
evwsgi.set_debug(0)    
evwsgi.run()
  
con.close()
Ejemplo n.º 4
0
Archivo: run.py Proyecto: Amli/fapws3
    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 qsize():
    print "defer queue size:",evwsgi.defer_queue_size()

evwsgi.start("0.0.0.0", "8080")
evwsgi.set_base_module(base)  
evwsgi.wsgi_cb(("/names/", names))
evwsgi.add_timer(2, qsize)
evwsgi.set_debug(0)    
evwsgi.run()
  
con.close()

Ejemplo n.º 5
0
    if rec:
        rec = rec[0]
        ndisp = rec.display + 1
        rec.set({'display': ndisp})
        rec.save()
        #uncomment the following to force a commit for each request
        #db.names.commit()
        return [
            template.render(**{
                "name": rec.name,
                "text": rec.text,
                "display": ndisp
            })
        ]
    else:
        return ["Name not found"]


def commit():
    con.commit()
    print "commit"


#he following trigger a commit every 2 seconds
evwsgi.add_timer(2, commit)
evwsgi.wsgi_cb(("/names/", names))
evwsgi.set_debug(0)
evwsgi.run()

con.close()