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

Unified Diff: cms/bin/test_server.py

Issue 5217703262420992: Issue 2181 - [cms] Test server should accept default page for subdirectories as well (Closed)
Patch Set: Created March 19, 2015, 10:31 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 | « no previous file | cms/sources.py » ('j') | cms/sources.py » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cms/bin/test_server.py
===================================================================
--- a/cms/bin/test_server.py
+++ b/cms/bin/test_server.py
@@ -37,23 +37,27 @@ mime_types = {
def get_data(path):
if source.has_static(path):
return source.read_static(path)
path = path.rstrip("/")
if path == "":
path = source.read_config().get("general", "defaultlocale")
- if "/" not in path:
- path = "%s/%s" % (path, source.read_config().get("general", "defaultpage"))
+ if "/" in path:
+ locale, page = path.split("/", 1)
+ else:
+ locale, page = path, ""
- locale, page = path.split("/", 1)
+ default_page = source.read_config().get("general", "defaultpage")
+ alternative_page = "/".join([page, default_page]).lstrip("/")
for format in converters.iterkeys():
- if source.has_page(page, format):
- return process_page(source, locale, page, format, "http://127.0.0.1:5000").encode("utf-8")
+ for p in (page, alternative_page):
+ if source.has_page(p, format):
+ return process_page(source, locale, p, format, "http://127.0.0.1:5000").encode("utf-8")
if source.has_localizable_file(locale, page):
return source.read_localizable_file(locale, page)
return None
@app.route("/", methods = ["GET"])
@app.route("/<path:path>", methods = ["GET"])
def show(path=""):
« no previous file with comments | « no previous file | cms/sources.py » ('j') | cms/sources.py » ('J')

Powered by Google App Engine
This is Rietveld