| Index: chrome/common/extensions/docs/server2/handler.py
|
| ===================================================================
|
| --- chrome/common/extensions/docs/server2/handler.py (revision 196927)
|
| +++ chrome/common/extensions/docs/server2/handler.py (working copy)
|
| @@ -10,6 +10,7 @@
|
| from appengine_wrappers import (
|
| DeadlineExceededError, IsDevServer, logservice, memcache, urlfetch, webapp)
|
| from branch_utility import BranchUtility
|
| +from patch_servlet import PatchData, PatchServlet
|
| from server_instance import ServerInstance
|
| import svn_constants
|
| import time
|
| @@ -40,7 +41,10 @@
|
| super(Handler, self).__init__(request, response)
|
|
|
| def _HandleGet(self, path):
|
| - channel_name, real_path = BranchUtility.SplitChannelNameFromPath(path)
|
| + channel_name, issue, real_path = (
|
| + PatchServlet.SplitPatchFromPath(path))
|
| + if issue is None:
|
| + channel_name, real_path = BranchUtility.SplitChannelNameFromPath(path)
|
|
|
| if channel_name == _DEFAULT_CHANNEL:
|
| self.redirect('/%s' % real_path)
|
| @@ -49,6 +53,10 @@
|
| if channel_name is None:
|
| channel_name = _DEFAULT_CHANNEL
|
|
|
| + branch_path = path.split(real_path, 1)[0].rstrip('/')
|
| + if branch_path != '':
|
| + branch_path = '/' + branch_path
|
| +
|
| # TODO(kalman): Check if |path| is a directory and serve path/index.html
|
| # rather than special-casing apps/extensions.
|
| if real_path.strip('/') == 'apps':
|
| @@ -56,10 +64,15 @@
|
| if real_path.strip('/') == 'extensions':
|
| real_path = 'extensions/index.html'
|
|
|
| - constructor = (
|
| - ServerInstance.CreateOnline if Handler.ALWAYS_ONLINE else
|
| - ServerInstance.GetOrCreateOffline)
|
| - server_instance = constructor(channel_name)
|
| + # Serving patched content requires an online server instance to fetch
|
| + # data from SVN and Rietveld.
|
| + if Handler.ALWAYS_ONLINE or issue is not None:
|
| + server_instance = ServerInstance.CreateOnline(channel_name,
|
| + branch_path,
|
| + PatchData.Create(issue))
|
| + else:
|
| + server_instance = ServerInstance.GetOrCreateOffline(channel_name,
|
| + branch_path)
|
|
|
| canonical_path = server_instance.path_canonicalizer.Canonicalize(real_path)
|
| if real_path != canonical_path:
|
| @@ -191,10 +204,6 @@
|
| def get(self):
|
| path = self.request.path
|
|
|
| - if path in ['favicon.ico', 'robots.txt']:
|
| - response.set_status(404)
|
| - return
|
| -
|
| if self._RedirectSpecialCases(path):
|
| return
|
|
|
|
|