| 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 PatchServlet
|
| from server_instance import ServerInstance
|
| import svn_constants
|
| import time
|
| @@ -34,13 +35,16 @@
|
| # However, we can't expect users of preview.py nor the dev server to run a
|
| # cronjob first, so, this is a hack allow that to be online all of the time.
|
| # TODO(kalman): achieve this via proper dependency injection.
|
| - ALWAYS_ONLINE = IsDevServer()
|
| + ALWAYS_ONLINE = True#IsDevServer()
|
|
|
| def __init__(self, request, response):
|
| 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,
|
| + issue)
|
| + else:
|
| + server_instance = ServerInstance.GetOrCreateOffline(channel_name,
|
| + branch_path)
|
|
|
| canonical_path = server_instance.path_canonicalizer.Canonicalize(real_path)
|
| if real_path != canonical_path:
|
| @@ -135,7 +148,8 @@
|
| # manifest.json files (for listing examples on the API reference pages),
|
| # but there are still images, CSS, etc.
|
| (svn_constants.STATIC_PATH, 'static/'),
|
| - (svn_constants.EXAMPLES_PATH, 'extensions/examples/')):
|
| + #(svn_constants.EXAMPLES_PATH, 'extensions/examples/')
|
| + ):
|
| try:
|
| # Note: don't try to short circuit any of this stuff. We want to run
|
| # the cron for all the directories regardless of intermediate failures.
|
| @@ -191,10 +205,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
|
|
|
|
|