rewrite in python/cherrypy