# HG changeset patch # User Tero Marttila # Date 1262895905 -7200 # Node ID 1a93b5a6efd0e39b1b8dac82de1b654ca24fcce4 # Parent fcd818eb5a713a15450c5b56a4195e1b889f1e52# Parent a5bca7b0cd8acb61746e2a756cecd71771ab6cea merge diff -r fcd818eb5a71 -r 1a93b5a6efd0 bin/pngtile.fcgi --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bin/pngtile.fcgi Thu Jan 07 22:25:05 2010 +0200 @@ -0,0 +1,34 @@ +#!/usr/bin/env python2.5 + +import flup.server.fcgi + +def main (app, bind=None) : + """ + Run as a non-threaded single-process non-multiplexed FastCGI server + """ + + # create WSGIServer + server = flup.server.fcgi.WSGIServer(app, + # try to supress threading + multithreaded=False, + multiprocess=False, + multiplexed=False, + + # specify the bind() address + bindAddress=bind, + + # leave as defaults for now + umask=None, + + # XXX: non-debug mode? + debug=True, + ) + + # run... threads :( + server.run() + +if __name__ == '__main__' : + import pngtile.wsgi + + main(pngtile.wsgi.application) + diff -r fcd818eb5a71 -r 1a93b5a6efd0 pngtile/wsgi.py --- a/pngtile/wsgi.py Thu Jan 07 22:24:30 2010 +0200 +++ b/pngtile/wsgi.py Thu Jan 07 22:25:05 2010 +0200 @@ -4,11 +4,11 @@ from werkzeug import Request, Response, responder from werkzeug import exceptions -import os.path +import os.path, os import pypngtile as pt -DATA_ROOT = os.path.abspath('data') +DATA_ROOT = os.environ.get("PNGTILE_DATA_PATH") or os.path.abspath('data/') IMAGE_CACHE = {} @@ -20,6 +20,7 @@ def dir_view (req, name, path) : prefix = os.path.dirname(req.script_root).rstrip('/') + script_prefix = req.script_root name = name.rstrip('/') @@ -42,9 +43,9 @@ listing = "\n".join( """
  • %(name)s
  • """ % dict( - url = '/'.join((prefix, name, item)), + url = '/'.join((script_prefix, name, item)), name = item, - ) for item in ['..'] + os.listdir(path) + ) for item in ['..'] + [i for i in os.listdir(path) if i.endswith('.png') or os.path.isdir(os.path.join(path, i))] ), ) @@ -130,6 +131,7 @@ # build absolute path image_path = os.path.abspath(os.path.join(DATA_ROOT, image_name)) + # ensure the path points inside the data root if not image_path.startswith(DATA_ROOT) :