Index: sitescripts/web.py |
diff --git a/sitescripts/web.py b/sitescripts/web.py |
index 2c0829b853566ddfa45f4252013cc42f074c01f0..dc4509b22a295b660d9e357e0f4ea64e773e3519 100644 |
--- a/sitescripts/web.py |
+++ b/sitescripts/web.py |
@@ -97,13 +97,18 @@ def form_handler(func): |
return wrapper |
+def get_handler(path): |
+ """Returns the URL handler for the given path if avaliable, otherwise |
+ throws a KeyError exception.""" |
+ try: |
+ handler = handlers[path] |
+ except KeyError: |
+ handler = handlers[re.sub(r"[^/]+$", "", path)] |
+ return handler |
+ |
def multiplex(environ, start_response): |
try: |
- path = environ["PATH_INFO"] |
- try: |
- handler = handlers[path] |
- except KeyError: |
- handler = handlers[re.sub(r"[^/]+$", "", path)] |
+ handler = get_handler(environ["PATH_INFO"]) |
except KeyError: |
start_response("404 Not Found", [("Content-Type", "text/plain")]) |
return ["Not Found"] |