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

Unified Diff: sitescripts/web.py

Issue 29328589: Issue 3122 - Add testpages.web.sitekey_frame URL handler (Closed)
Patch Set: Addressed feedback Created Oct. 7, 2015, 4:06 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 | « sitescripts/utils.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
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"]
« no previous file with comments | « sitescripts/utils.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld