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',
class index:
def GET(self):
- render('index', locals())
+ return render('index', locals())
def POST(self):
input = web.input()
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'],
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):
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):
#rulers = map(lambda x: x, rulers)
- render('gallery', locals())
+ return render('gallery', locals())
def POST(self, ruler_url):
input = web.input()
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):
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]
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()