11
10
from paste import httpexceptions
13
12
from loggerhead.apps import static_app
13
from loggerhead.controllers.changelog_ui import ChangeLogUI
14
from loggerhead.controllers.inventory_ui import InventoryUI
14
15
from loggerhead.controllers.annotate_ui import AnnotateUI
16
from loggerhead.controllers.revision_ui import RevisionUI
15
17
from loggerhead.controllers.atom_ui import AtomUI
16
from loggerhead.controllers.changelog_ui import ChangeLogUI
17
from loggerhead.controllers.diff_ui import DiffUI
18
18
from loggerhead.controllers.download_ui import DownloadUI
19
from loggerhead.controllers.filediff_ui import FileDiffUI
20
from loggerhead.controllers.inventory_ui import InventoryUI
21
from loggerhead.controllers.revision_ui import RevisionUI
22
from loggerhead.controllers.revlog_ui import RevLogUI
23
19
from loggerhead.controllers.search_ui import SearchUI
20
from loggerhead.controllers.diff_ui import DiffUI
24
21
from loggerhead.history import History
25
22
from loggerhead import util
30
25
class BranchWSGIApp(object):
32
27
def __init__(self, branch, friendly_name=None, config={},
33
graph_cache=None, branch_link=None, is_root=False,
28
graph_cache=None, branch_link=None):
35
29
self.branch = branch
36
30
self._config = config
37
31
self.friendly_name = friendly_name
38
32
self.branch_link = branch_link # Currently only used in Launchpad
39
self.log = logging.getLogger('loggerhead.%s' % friendly_name)
33
self.log = logging.getLogger('loggerhead.%s' % (friendly_name,))
40
34
if graph_cache is None:
41
35
graph_cache = bzrlib.lru_cache.LRUCache()
42
36
self.graph_cache = graph_cache
43
self.is_root = is_root
44
self.served_url = served_url
46
38
def get_history(self):
47
39
_history = History(self.branch, self.graph_cache)
70
62
return request.construct_url(
71
63
self._environ, script_name=self._url_base,
72
path_info=unicode('/'.join(args)).encode('utf-8'),
64
path_info='/'.join(args),
75
67
def context_url(self, *args, **kw):
106
96
if self._static_url_base is None:
107
97
self._static_url_base = self._url_base
108
98
self._environ = environ
109
if self.served_url is _DEFAULT:
110
self.served_url = self.url([])
111
99
path = request.path_info_pop(environ)
113
101
raise httpexceptions.HTTPMovedPermanently(
119
107
raise httpexceptions.HTTPNotFound()
120
108
self.branch.lock_read()
123
c = cls(self, self.get_history)
124
return c(environ, start_response)
126
environ['exc_info'] = sys.exc_info()
127
environ['branch'] = self
110
c = cls(self, self.get_history())
111
return c(environ, start_response)
130
113
self.branch.unlock()