~loggerhead-team/loggerhead/trunk-rich

« back to all changes in this revision

Viewing changes to loggerhead/apps/branch.py

  • Committer: Ian Clatworthy
  • Date: 2010-04-13 08:46:25 UTC
  • mto: This revision was merged to the branch mainline in revision 405.
  • Revision ID: ian.clatworthy@canonical.com-20100413084625-ih0ld6rreq3ia0l5
Minor tweaks to Tres' content

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2008-2011 Canonical Ltd.
 
1
# Copyright (C) 2008, 2009 Canonical Ltd.
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
21
21
import sys
22
22
 
23
23
import bzrlib.branch
24
 
import bzrlib.errors
25
24
import bzrlib.lru_cache
26
25
 
27
26
from paste import request
29
28
 
30
29
from loggerhead.apps import static_app
31
30
from loggerhead.controllers.annotate_ui import AnnotateUI
32
 
from loggerhead.controllers.view_ui import ViewUI
33
31
from loggerhead.controllers.atom_ui import AtomUI
34
32
from loggerhead.controllers.changelog_ui import ChangeLogUI
35
33
from loggerhead.controllers.diff_ui import DiffUI
90
88
            if v is not None:
91
89
                qs.append('%s=%s' % (k, urllib.quote(v)))
92
90
        qs = '&'.join(qs)
93
 
        path_info = urllib.quote(
94
 
            unicode('/'.join(args)).encode('utf-8'), safe='/~:')
95
 
        if qs:
96
 
            path_info += '?' + qs
97
 
        return self._url_base + path_info
98
 
 
99
 
    def absolute_url(self, *args, **kw):
100
 
        rel_url = self.url(*args, **kw)
101
 
        return request.resolve_relative_url(rel_url, self._environ)
 
91
        return request.construct_url(
 
92
            self._environ, script_name=self._url_base,
 
93
            path_info=unicode('/'.join(args)).encode('utf-8'),
 
94
            querystring=qs)
102
95
 
103
96
    def context_url(self, *args, **kw):
104
97
        kw = util.get_context(**kw)
125
118
        'files': InventoryUI,
126
119
        'revision': RevisionUI,
127
120
        'search': SearchUI,
128
 
        'view': ViewUI,
129
121
        }
130
122
 
131
123
    def last_updated(self):
153
145
            else:
154
146
                # Loggerhead only supports serving .bzr/ on local branches, so
155
147
                # we shouldn't suggest something that won't work.
156
 
                try:
157
 
                    util.local_path_from_url(self.branch.base)
 
148
                if self.branch.base.startswith('file://'):
158
149
                    self.served_url = self.url([])
159
 
                except bzrlib.errors.InvalidURL:
 
150
                else:
160
151
                    self.served_url = None
161
152
        path = request.path_info_pop(environ)
162
153
        if not path:
163
154
            raise httpexceptions.HTTPMovedPermanently(
164
 
                self.absolute_url('/changes'))
 
155
                self._url_base + '/changes')
165
156
        if path == 'static':
166
157
            return static_app(environ, start_response)
167
158
        cls = self.controllers_dict.get(path)