]> projects.mako.cc - yourule/commitdiff
updated to the newer vsions of web.py
authorBenjamin Mako Hill <mako@atdot.cc>
Sun, 10 Apr 2011 04:58:49 +0000 (00:58 -0400)
committerBenjamin Mako Hill <mako@atdot.cc>
Sun, 10 Apr 2011 04:58:49 +0000 (00:58 -0400)
yourule.py

index d18e1e684551d9af49d266eb69d10d5792ff95a6..0d8adbc8a281063ffefc8052be6d7c2750f54022 100755 (executable)
@@ -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()
 

Benjamin Mako Hill || Want to submit a patch?