1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
# Copyright 2009 Canonical Ltd. This software is licensed under the
# GNU Affero General Public License version 3 (see the file LICENSE).
"""Browser code used to implement virtual '.bzr' directories."""
__metaclass__ = type
__all__ = [
'BranchRef'
]
from zope.interface import implements
from zope.publisher.interfaces.browser import IBrowserPublisher
from lp.code.interfaces.branchref import IBranchRef
from lp.services.config import config
from lp.services.webapp import (
Navigation,
stepthrough,
stepto,
)
class BranchRef:
implements(IBranchRef)
def __init__(self, branch):
self.branch = branch
# XXX jamesh 2006-09-26:
# Eventually we will be able to change this to serve a simple HTTP
# redirect for 'branch-format' and have bzr do the rest. However,
# current Bazaar releases would continue to request branch data files
# at this location.
#
# Synthesising a branch reference provides the desired behaviour with
# current Bazaar releases, however.
class BranchRefNavigation(Navigation):
usedfor = IBranchRef
@stepto('branch-format')
def branch_format(self):
return StaticContentView('Bazaar-NG meta directory, format 1\n')
@stepthrough('branch')
def traverse_branch(self, name):
if name == 'format':
return StaticContentView('Bazaar-NG Branch Reference Format 1\n')
elif name == 'location':
return StaticContentView(config.codehosting.supermirror_root +
self.context.branch.unique_name)
else:
return None
class StaticContentView:
implements(IBrowserPublisher)
def __init__(self, contents):
self.contents = contents
def __call__(self):
return self.contents
def browserDefault(self, request):
return self, ()
|