10
10
from zope.component import getUtility
12
12
from canonical.config import config
13
from canonical.launchpad.webapp.adapter import (
14
clear_request_started,
13
17
from lp.code.interfaces.branchlookup import IBranchLookup
14
18
from lp.code.interfaces.codehosting import BRANCH_ID_ALIAS_PREFIX
15
19
from lp.codehosting.vfs import branch_id_to_path
92
96
# Codebrowse generates references to its images and stylesheets
93
97
# starting with "/static", so pass them on unthinkingly.
96
if resource_location.startswith('/static/'):
97
r = self._codebrowse_url(resource_location)
100
branch_id, trailing, cached = self._getBranchIdAndTrailingPath(
102
if branch_id is None:
103
if resource_location.startswith('/' + BRANCH_ID_ALIAS_PREFIX):
106
r = self._codebrowse_url(resource_location)
99
# Tell the webapp adapter that we are in a request, so that DB
100
# statement timeouts will be applied.
101
set_request_started()
104
if resource_location.startswith('/static/'):
105
r = self._codebrowse_url(resource_location)
108
if trailing.startswith('/.bzr'):
110
config.codehosting.internal_branch_by_id_root,
111
branch_id_to_path(branch_id), trailing[1:])
108
branch_id, trailing, cached = self._getBranchIdAndTrailingPath(
110
if branch_id is None:
111
if resource_location.startswith('/' + BRANCH_ID_ALIAS_PREFIX):
114
r = self._codebrowse_url(resource_location)
113
r = self._codebrowse_url(resource_location)
116
if trailing.startswith('/.bzr'):
118
config.codehosting.internal_branch_by_id_root,
119
branch_id_to_path(branch_id), trailing[1:])
121
r = self._codebrowse_url(resource_location)
123
clear_request_started()
114
124
self.logger.info(
115
125
"%r -> %r (%fs, cache: %s)",
116
126
resource_location, r, time.time() - T, cached)