Commits

Anonymous committed b9e9f33

Make templates configurable

  • Participants
  • Parent commits 2f103c1

Comments (0)

Files changed (4)

 
 [app:main]
 use = egg:mush
+templates = %(here)s/mush/templates
 
 # WARNING: *THE LINE BELOW MUST BE UNCOMMENTED ON A PRODUCTION ENVIRONMENT*
 # Debug mode will enable the interactive debugging tool, allowing ANYONE to
 import urls
+import mush.configuration
 
 def make_app(global_config, **local_config):
+    from genshi.template import TemplateLoader
+    mush.configuration.loader = TemplateLoader([local_config['templates']])
     return urls.urls

mush/configuration.py

+vars = {}
 from cgi import parse_qs
 import os.path
 from urllib import unquote_plus
-
-from genshi.template import TemplateLoader
-loader = TemplateLoader(['/home/sean/Projects/mush/mush/templates/'])
-
 import envutil
 import overlap
+import mush.configuration
 
-# handlers
-# -----------
-
-def test(environ, start_response):
-    start_response("202 Accepted", [
-        ('Content-Type', 'text/plain'),
-        ('Location', 'http://zcologia.com/mush.html'),
-        ]
-    )
-    return ['go to http://zcologia.com/mush.html']
 
 def self_buffer_intersection_html(environ, start_response):
-    tmpl = loader.load('buffer-intersection-index.html')
+    tmpl = mush.configuration.loader.load('buffer-intersection-index.html')
     stream = tmpl.generate(
         title='Sphere of Influence Intersections',
         site_url=envutil.site_url(environ)
     q_url = params.get('url', [None])[0]
     d = params.get('d', [1.0])[0]
     result = overlap.self_buffer_intersection(q_url, d)
-    tmpl = loader.load('buffer-intersection-feed.xml')
+    tmpl = mush.configuration.loader.load('buffer-intersection-feed.xml')
     self_url = envutil.request_url(environ)
     alt_url = "%s/%s" % (envutil.site_url(environ), 'index.html')
     stream = tmpl.generate(
     return [stream.render()]
 
 def pair_buffer_intersection_html(environ, start_response):
-    tmpl = loader.load('buffer-intersection2-index.html')
+    tmpl = mush.configuration.loader.load('buffer-intersection2-index.html')
     stream = tmpl.generate(
         title='Sphere of Influence Intersections, 2 Feeds',
         site_url=envutil.site_url(environ)
     url2 = params.get('url2', [None])[0]
     d = params.get('d', [1.0])[0]
     result = overlap.pair_buffer_intersection(url1, url2, d)
-    tmpl = loader.load('buffer-intersection-feed.xml')
+    tmpl = mush.configuration.loader.load('buffer-intersection-feed.xml')
     self_url = envutil.request_url(environ)
     alt_url = "%s/%s" % (envutil.site_url(environ), 'index.html')
     stream = tmpl.generate(