From: Benjamin Mako Hill Date: Sun, 10 Apr 2011 04:58:49 +0000 (-0400) Subject: updated to the newer vsions of web.py X-Git-Url: https://projects.mako.cc/source/yourule/commitdiff_plain/577e92b2e62bca78cf2a096c838fe3c4a7945006 updated to the newer vsions of web.py --- diff --git a/yourule.py b/yourule.py index d18e1e6..0d8adbc 100755 --- a/yourule.py +++ b/yourule.py @@ -41,7 +41,7 @@ def render(filename, vars={}): tmpl = jinja_env.get_template(filename + '.tmpl') vars['homepath'] = web.ctx.homepath vars['ctx'] = web.ctx - print tmpl.render(vars) + return tmpl.render(vars) # the url map for the application urls = ( '/?', 'index', @@ -94,7 +94,7 @@ class Ruler(object): class index: def GET(self): - render('index', locals()) + return render('index', locals()) def POST(self): input = web.input() @@ -105,7 +105,7 @@ class index: pixel_width = input['pixel_width'] unit_width = input['unit_width'] units = input['units'] - render('index', locals()) + return render('index', locals()) else: ruler = Ruler(pixel_width = input['pixel_width'], unit_width = input['unit_width'], @@ -122,7 +122,7 @@ class show_ruler: other_unit, other_unit_url = get_other_unit(ruler_url) - render('show_ruler', locals()) + return render('show_ruler', locals()) class ruler_img: def GET(self, pixel_width=None, unit_width=None, units=None, ext=None): @@ -145,14 +145,14 @@ class ruler_img: web.header("Content-Type", "image/%s" % ext) if ext == 'svg+xml': - sys.stdout.write(ruler.getxml()) + return(ruler.getxml()) else: pin, pout = os.popen2('convert -size %sx%s - %s:-' % \ (pixel_width, ruler_height, ext)) pin.write(ruler.getxml()) pin.close() - sys.stdout.write(pout.read()) + return(pout.read()) class gallery: def GET(self, ruler_url): @@ -168,7 +168,7 @@ class gallery: #rulers = map(lambda x: x, rulers) - render('gallery', locals()) + return render('gallery', locals()) def POST(self, ruler_url): input = web.input() @@ -193,7 +193,7 @@ class gallery: rulers = store.find(Ruler, Ruler.visible == 1) #rulers.order_by(Ruler.model) - render('gallery', locals()) + return render('gallery', locals()) class delete: def GET(self, id): @@ -212,7 +212,7 @@ class undelete: class css: def GET(self): - render('style.css') + return render('style.css') def get_other_unit(url): pixel_width, unit_width, units = process_ruler_url(url)[0:3] @@ -258,5 +258,6 @@ web.webapi.internalerror = web.debugerror if __name__ == "__main__": web.run(urls, globals(), web.reloader) -application = web.wsgifunc(web.webpyfunc(urls, globals())) +app = web.application(urls, globals(), autoreload=False) +application = app.wsgifunc()