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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
|
# Copyright 2009 Canonical Ltd. This software is licensed under the
# GNU Affero General Public License version 3 (see the file LICENSE).
"""The webapp package contains infrastructure that is common across Launchpad
that is to do with aspects such as security, menus, zcml, tales and so on.
This module also has an API for use by the application.
"""
__metaclass__ = type
__all__ = [
'action',
'ApplicationMenu',
'canonical_name',
'canonical_url',
'ContextMenu',
'custom_widget',
'enabled_with_permission',
'expand_numbers',
'FacetMenu',
'GetitemNavigation',
'LaunchpadEditFormView',
'LaunchpadFormView',
'LaunchpadView',
'LaunchpadXMLRPCView',
'Link',
'Navigation',
'NavigationMenu',
'nearest',
'redirection',
'safe_action',
'sorted_dotted_numbers',
'sorted_version_numbers',
'StandardLaunchpadFacets',
'stepthrough',
'stepto',
'structured',
'UnsafeFormGetSubmissionError',
'urlappend',
'urlparse',
'urlsplit',
'Utf8PreferredCharsets',
]
from lp.services.webapp.launchpadform import (
action,
custom_widget,
LaunchpadEditFormView,
LaunchpadFormView,
safe_action,
)
from lp.services.webapp.menu import (
ApplicationMenu,
ContextMenu,
enabled_with_permission,
FacetMenu,
Link,
NavigationMenu,
structured,
)
from lp.services.webapp.preferredcharsets import Utf8PreferredCharsets
from lp.services.webapp.publisher import (
canonical_name,
canonical_url,
LaunchpadView,
LaunchpadXMLRPCView,
Navigation,
nearest,
redirection,
stepthrough,
stepto,
)
from lp.services.webapp.sorting import (
expand_numbers,
sorted_dotted_numbers,
sorted_version_numbers,
)
from lp.services.webapp.url import (
urlappend,
urlparse,
urlsplit,
)
class GetitemNavigation(Navigation):
"""Base class for navigation where fall-back traversal uses context[name].
"""
def traverse(self, name):
return self.context[name]
class StandardLaunchpadFacets(FacetMenu):
"""The standard set of facets that most faceted content objects have."""
# provide your own 'usedfor' in subclasses.
# usedfor = IWhatever
links = ['overview', 'branches', 'bugs', 'specifications', 'translations',
'answers']
enable_only = ['overview', 'bugs', 'specifications', 'translations']
defaultlink = 'overview'
def _filterLink(self, name, link):
if link.site is None:
if name == 'specifications':
link.site = 'blueprints'
elif name == 'branches':
link.site = 'code'
elif name == 'translations':
link.site = 'translations'
elif name == 'answers':
link.site = 'answers'
elif name == 'bugs':
link.site = 'bugs'
else:
link.site = 'mainsite'
return link
def overview(self):
text = 'Overview'
return Link('', text)
def translations(self):
text = 'Translations'
return Link('', text)
def bugs(self):
text = 'Bugs'
return Link('', text)
def answers(self):
# This facet is visible but unavailable by default.
# See the enable_only list above.
text = 'Answers'
summary = 'Launchpad Answer Tracker'
return Link('', text, summary)
def specifications(self):
text = 'Blueprints'
summary = 'Blueprints and specifications'
return Link('', text, summary)
def branches(self):
# this is disabled by default, because relatively few objects have
# branch views
text = 'Code'
summary = 'View related code'
return Link('', text, summary=summary)
|