1 #!/usr/bin/env python 2 #!/path/to/python -u 3 from config import py as cfg 4 if cfg.has_key("codebase"): 5 import sys 6 sys.path.insert(0, cfg["codebase"]) 7 if __name__ == '__main__': 8 import os, sys 9 from Pyblosxom.pyblosxom import PyBlosxom 10 11 env = {} 12 # names taken from wsgi instead of inventing something new 13 env['wsgi.input'] = sys.stdin 14 env['wsgi.errors'] = sys.stderr 15 env['wsgi.url_scheme'] = "http" 16 if os.environ.get("HTTPS") in ('yes','on','1'): 17 env['wsgi.url_scheme'] = "https" 18 # setup url_scheme for static rendering 19 if not os.environ.get("REQUEST_METHOD", ""): 20 if 'base_url' in cfg: 21 env['wsgi.url_scheme'] = cfg['base_url'][:cfg['base_url'].find("://")] 22 for mem in ["HTTP_HOST", "HTTP_USER_AGENT", "HTTP_REFERER", "PATH_INFO", 23 "QUERY_STRING", "REMOTE_ADDR", "REQUEST_METHOD", "REQUEST_URI", 24 "SCRIPT_NAME", "HTTP_IF_NONE_MATCH", "HTTP_IF_MODIFIED_SINCE", 25 "HTTP_COOKIE", "CONTENT_LENGTH", "HTTP_ACCEPT", "HTTP_ACCEPT_ENCODING"]: 26 env[mem] = os.environ.get(mem, "") 27 p = PyBlosxom(cfg, env) 28 if not env.get("REQUEST_METHOD", ""): 29 if len(sys.argv) > 1 and sys.argv[1] == "--static": 30 if "--incremental" in sys.argv: 31 incremental = 1 32 else: 33 incremental = 0 34 p.runStaticRenderer(incremental) 35 else: 36 p.testInstallation() 37 else: 38 p.run() 39 response = p.getResponse() 40 response.sendHeaders(sys.stdout) 41 response.sendBody(sys.stdout)