Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(205)

Unified Diff: v2/urls.py

Issue 70870043: Quick outline of simplified rietveld2 framework based on jinja2
Patch Set: Revised handler registration, more example handlers, more common processing in servlet. Created 9 years, 12 months ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « v2/templates/echo.html ('k') | v2_main.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: v2/urls.py
===================================================================
new file mode 100644
--- /dev/null
+++ b/v2/urls.py
@@ -0,0 +1,69 @@
+# Copyright 2014 Google Inc.
+
+"""Set up the rietveld2 webapp and register all HTTP request handlers.
+
+Rietveld2 uses the webapp2 framework. Each web page or group of related
+JSON request handlers is organized into a servlet class.
+"""
+
+import webapp2
+from webapp2_extras import routes
+
+from v2 import api
+from v2 import servlet
+
+
+HTML_UI_ROUTES = [
+ # Top level pages
+ webapp2.Route(r'/', servlet.EchoHTML, 'home-page'),
+ webapp2.Route(r'/rawimage', servlet.RawExample),
+ webapp2.Route(r'/mine', servlet.EchoHTML, 'my-issues-page'),
+ webapp2.Route(r'/stared', servlet.EchoHTML, 'starred-issue-page'),
+ webapp2.Route(r'/all', servlet.EchoHTML, 'all-issues-page'),
+ webapp2.Route(r'/search', servlet.EchoHTML, 'issue-search-page'),
+
+ # Issue detail pages
+ routes.PathPrefixRoute(r'/<issue_id:\d+>', [
+ webapp2.Route(r'/', servlet.EchoHTML, 'issue-detail-page'),
+ webapp2.Route(r'/patch/<patchset_id:\d+>/<patch_id:\d+>',
+ servlet.EchoHTML, 'unified-diff-page'),
+ webapp2.Route(r'/diff/<patchset_id:\d+>/<path:.+>',
+ servlet.EchoHTML, 'side-by-side-diff'),
+ # TODO(jrobbins): more handlers for edit, publish, delete, etc.
+ ]),
+]
+
+
+def route_nested_entities(spec, *path_handler_pairs):
+ """Accumulate handlers along a longer and longer route spec."""
+ routes = []
+ for spec_part, handler in path_handler_pairs:
+ spec += '/' + spec_part
+ routes.append(webapp2.Route(spec, handler))
+ return routes
+
+
+API_ROUTES = (
+ # Issue -> Patchset -> Patch -> Comment
+ route_nested_entities(
+ '',
+ ('Issue', api.IssueCollectionJSON),
+ ('<issue_id:\d+>', api.IssueJSON),
+ ('Patchset', api.PatchCollectionJSON),
+ ('<ps_id:\d+>', api.PatchsetJSON),
+ ('Patch', api.PatchCollectionJSON),
+ ('<patch_id:\d+>', api.PatchJSON),
+ ('Comment', api.CommentCollectionJSON),
+ ('<comment_id:\d+>', api.CommentJSON)) +
+ # Issue -> Message
+ route_nested_entities(
+ '/Issue/<issue_id:\d+>',
+ ('Message', api.MessageCollectionJSON),
+ ('<message_id:\d+>', api.MessageJSON))
+ )
+
+
+ROUTES = [
+ routes.PathPrefixRoute(r'/v2', HTML_UI_ROUTES),
+ routes.PathPrefixRoute(r'/v2/api', API_ROUTES),
+ ]
« no previous file with comments | « v2/templates/echo.html ('k') | v2_main.py » ('j') | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b