Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: sitescripts/web.py

Issue 6209629180657664: Issue 2169 - Unify development and production implementation of multiplexer (Closed)
Patch Set: Created March 23, 2015, 4:23 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « multiplexer.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sitescripts/web.py
===================================================================
--- a/sitescripts/web.py
+++ b/sitescripts/web.py
@@ -18,6 +18,7 @@
import base64
import imp
import importlib
+import re
from sitescripts.utils import get_config
handlers = {}
@@ -58,6 +59,19 @@
[("WWW-Authenticate", 'Basic realm="%s"' % realm)])
return ""
+def multiplex(environ, start_response):
+ try:
+ path = environ["PATH_INFO"]
+ try:
+ handler = handlers[path]
+ except KeyError:
+ handler = handlers[re.sub(r"[^/]+$", "", path)]
+ except KeyError:
+ start_response("404 Not Found", [("Content-Type", "text/plain")])
+ return ["Not Found"]
+
+ return handler(environ, start_response)
+
for module in set(get_config().options("multiplexer")) - set(get_config().defaults()):
module_path = get_config().get("multiplexer", module)
if module_path:
« no previous file with comments | « multiplexer.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld