Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(738)

Side by Side Diff: chrome/common/extensions/docs/server2/handler.py

Issue 736773002: Docserver: Add commit history and _reset_commit servlet (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/common/extensions/docs/server2/app.yaml ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 import time 5 import time
6 6
7 from appengine_wrappers import taskqueue 7 from appengine_wrappers import taskqueue
8 from commit_tracker import CommitTracker 8 from commit_tracker import CommitTracker
9 from cron_servlet import CronServlet 9 from cron_servlet import CronServlet
10 from instance_servlet import InstanceServlet 10 from instance_servlet import InstanceServlet
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 ''' 53 '''
54 def __init__(self, request): 54 def __init__(self, request):
55 Servlet.__init__(self, request) 55 Servlet.__init__(self, request)
56 56
57 def Get(self): 57 def Get(self):
58 object_store_creator = ObjectStoreCreator(start_empty=False) 58 object_store_creator = ObjectStoreCreator(start_empty=False)
59 commit_tracker = CommitTracker(object_store_creator) 59 commit_tracker = CommitTracker(object_store_creator)
60 return Response.Ok(commit_tracker.Get(self._request.path).Get()) 60 return Response.Ok(commit_tracker.Get(self._request.path).Get())
61 61
62 62
63 class _ResetCommitServlet(Servlet):
64 '''Writes a new commit ID to the commit cache. For example:
65
66 /_reset_commit/master/123456
67
68 will reset the 'master' commit ID to '123456'.
69 '''
70 def __init__(self, request):
71 Servlet.__init__(self, request)
72
73 def Get(self):
74 object_store_creator = ObjectStoreCreator(start_empty=False)
75 commit_tracker = CommitTracker(object_store_creator)
76 commit_name, commit_id = self._request.path.split('/')
not at google - send to devlin 2014/11/18 23:05:48 Is there some kind of validation that you can do o
77 commit_tracker.Set(commit_name, commit_id).Get()
78 return Response.Ok('Done.')
79
80
63 _SERVLETS = { 81 _SERVLETS = {
64 'cron': CronServlet, 82 'cron': CronServlet,
65 'enqueue': _EnqueueServlet, 83 'enqueue': _EnqueueServlet,
66 'patch': PatchServlet, 84 'patch': PatchServlet,
67 'query_commit': _QueryCommitServlet, 85 'query_commit': _QueryCommitServlet,
68 'refresh': RefreshServlet, 86 'refresh': RefreshServlet,
87 'reset_commit': _ResetCommitServlet,
69 'test': TestServlet, 88 'test': TestServlet,
70 } 89 }
71 90
72 91
73 class Handler(Servlet): 92 class Handler(Servlet):
74 def Get(self): 93 def Get(self):
75 path = self._request.path 94 path = self._request.path
76 95
77 if path.startswith('_'): 96 if path.startswith('_'):
78 servlet_path = path[1:] 97 servlet_path = path[1:]
79 if not '/' in servlet_path: 98 if not '/' in servlet_path:
80 servlet_path += '/' 99 servlet_path += '/'
81 servlet_name, servlet_path = servlet_path.split('/', 1) 100 servlet_name, servlet_path = servlet_path.split('/', 1)
82 servlet = _SERVLETS.get(servlet_name) 101 servlet = _SERVLETS.get(servlet_name)
83 if servlet is None: 102 if servlet is None:
84 return Response.NotFound('"%s" servlet not found' % servlet_path) 103 return Response.NotFound('"%s" servlet not found' % servlet_path)
85 else: 104 else:
86 servlet_path = path 105 servlet_path = path
87 servlet = _DEFAULT_SERVLET 106 servlet = _DEFAULT_SERVLET
88 107
89 return servlet(Request(servlet_path, 108 return servlet(Request(servlet_path,
90 self._request.host, 109 self._request.host,
91 self._request.headers, 110 self._request.headers,
92 self._request.arguments)).Get() 111 self._request.arguments)).Get()
OLDNEW
« no previous file with comments | « chrome/common/extensions/docs/server2/app.yaml ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698