X-Git-Url: https://projects.mako.cc/source/yourule/blobdiff_plain/ba471ef56c488ae95dac054033c81a3541cda71c..c61d6a6300242da86d532d34bb0506e04c9de658:/yourule.py diff --git a/yourule.py b/yourule.py index 9e933d6..d6f44bd 100755 --- a/yourule.py +++ b/yourule.py @@ -4,27 +4,32 @@ from __future__ import division import web import sys, os, re from storm.locals import * + +# recalculate the path based on the location of the file +sys.path.append(os.path.dirname(__file__)) from svgruler import SVGRuler from jinja import Environment, FileSystemLoader jinja_env = Environment('<%', '%>', '<%=', '%>', '<%#', '%>', - loader=FileSystemLoader('templates/')) + loader=FileSystemLoader(os.path.dirname(__file__) + "/templates/")) def render(filename, vars): web.header("Content-Type","text/html; charset=utf-8") tmpl = jinja_env.get_template(filename + '.tmpl') print tmpl.render(vars) - web.debug(web.ctx) + print web.ctx # the url map for the application -urls = ( '/', 'index', +urls = ( '/?', 'index', '/ruler_([0-9\.]+)px_([0-9\.]+)([A-Za-z]+).(svg|png|jpg)', 'ruler_img', '/show/(.*(svg|png|jpg))', 'show_ruler', '/gallery(.*)', 'gallery', '/delete/(\d+)', 'delete', '/undelete/(\d+)', 'undelete') -database = create_database("sqlite:yourule.db") +database = create_database("sqlite:%s/db/yourule.db" % + os.path.dirname(__file__)) + store = Store(database) class Ruler(object): @@ -220,5 +225,5 @@ web.webapi.internalerror = web.debugerror if __name__ == "__main__": web.run(urls, globals(), web.reloader) -#application = web.wsgifunc(web.webpyfunc(urls, globals())) +application = web.wsgifunc(web.webpyfunc(urls, globals()))