14557.1.20
by Curtis Hovey
Updated copyright. |
1 |
# Copyright 2009-2011 Canonical Ltd. This software is licensed under the
|
8687.15.18
by Karl Fogel
Add the copyright header block to files under lib/canonical/. |
2 |
# GNU Affero General Public License version 3 (see the file LICENSE).
|
2458
by Canonical.com Patch Queue Manager
[r=kiko] remove more dirty database imports |
3 |
|
4 |
"""Content classes for the 'home pages' of the subsystems of Launchpad."""
|
|
5 |
||
3617.1.2
by Steve Alexander
removed lib/canonical/rosetta, and changed _clearCache to the public API clear_current_connection_cache |
6 |
__all__ = [ |
4483.4.4
by Barry Warsaw
Flesh out the XMLRPC implementation of IRequestedMailingListAPI, along with |
7 |
'BazaarApplication', |
11073.1.6
by Guilherme Salgado
Fix the IAbsoluteURL issue |
8 |
'CodeImportSchedulerApplication', |
4934.3.9
by Elliot Murphy
Renaming from Feed to Feeds. |
9 |
'FeedsApplication', |
4483.4.4
by Barry Warsaw
Flesh out the XMLRPC implementation of IRequestedMailingListAPI, along with |
10 |
'MailingListApplication', |
11 |
'MaloneApplication', |
|
6002.3.11
by Graham Binns
Renamed IExternalBugTrackerTokenApplication to IPrivateMaloneApplication. |
12 |
'PrivateMaloneApplication', |
4483.4.4
by Barry Warsaw
Flesh out the XMLRPC implementation of IRequestedMailingListAPI, along with |
13 |
'RosettaApplication', |
10065.2.3
by Guilherme Salgado
Move the test openid views under a newly created testopenid vhost. |
14 |
'TestOpenIDApplication', |
4483.4.4
by Barry Warsaw
Flesh out the XMLRPC implementation of IRequestedMailingListAPI, along with |
15 |
]
|
3617.1.2
by Steve Alexander
removed lib/canonical/rosetta, and changed _clearCache to the public API clear_current_connection_cache |
16 |
|
1861
by Canonical.com Patch Queue Manager
various clean-up of FOAFApplication and DOAPApplication, removal of unused things, moval of zcml into launchpad/zcml/doap.zcml and launchpad/zcml/foaf.zcml. moval of FOAFApplication and DOAPApplication into systemhomes.py, introdution of 'titleheader' slot in the main template. [trivial] |
17 |
__metaclass__ = type |
18 |
||
7368.5.19
by Gavin Panella
Post-review fixes. |
19 |
import codecs |
7182.3.2
by Gary Poster
change code to keep launchpad code in launchpad, not lazr; add tests. Once (or if) lint is happy, this should be ready for review. |
20 |
import os |
21 |
||
11403.1.4
by Henning Eggers
Reformatted imports using format-imports script r32. |
22 |
from lazr.restful import ServiceRootResource |
23 |
from lazr.restful.interfaces import ITopLevelEntryLink |
|
2458
by Canonical.com Patch Queue Manager
[r=kiko] remove more dirty database imports |
24 |
from zope.component import getUtility |
1861
by Canonical.com Patch Queue Manager
various clean-up of FOAFApplication and DOAPApplication, removal of unused things, moval of zcml into launchpad/zcml/doap.zcml and launchpad/zcml/foaf.zcml. moval of FOAFApplication and DOAPApplication into systemhomes.py, introdution of 'titleheader' slot in the main template. [trivial] |
25 |
from zope.interface import implements |
4337.1.7
by Stuart Bishop
Add OpenIDApplication and fix a few obviously broken interfaces |
26 |
|
14605.1.1
by Curtis Hovey
Moved canonical.config to lp.services. |
27 |
from lp.services.config import config |
14600.2.2
by Curtis Hovey
Moved webapp to lp.services. |
28 |
from lp.services.webapp.interfaces import ( |
11403.1.4
by Henning Eggers
Reformatted imports using format-imports script r32. |
29 |
IAPIDocRoot, |
30 |
ICanonicalUrlData, |
|
11882.2.3
by Jonathan Lange
And that's the rest of them. |
31 |
ILaunchBag, |
32 |
)
|
|
12221.9.38
by Tim Penhey
Fix the field validation code for DuplicateBug to use the right error. |
33 |
from lp.bugs.errors import InvalidBugTargetType |
8590.2.2
by Tim Penhey
Fix the fallout in the zcml and other imports. |
34 |
from lp.bugs.interfaces.bug import ( |
11403.1.4
by Henning Eggers
Reformatted imports using format-imports script r32. |
35 |
CreateBugParams, |
36 |
IBugSet, |
|
37 |
)
|
|
11882.2.3
by Jonathan Lange
And that's the rest of them. |
38 |
from lp.bugs.interfaces.bugtask import ( |
39 |
BugTaskSearchParams, |
|
40 |
IBugTaskSet, |
|
41 |
)
|
|
42 |
from lp.bugs.interfaces.bugtracker import IBugTrackerSet |
|
43 |
from lp.bugs.interfaces.bugwatch import IBugWatchSet |
|
14560.2.16
by Curtis Hovey
Moved IPrivateMaloneApplication to lp.bugs. |
44 |
from lp.bugs.interfaces.malone import ( |
45 |
IMaloneApplication, |
|
46 |
IPrivateMaloneApplication, |
|
47 |
)
|
|
14560.2.18
by Curtis Hovey
Moved IBazaarApplication to lp.code. |
48 |
from lp.code.interfaces.codehosting import ( |
49 |
IBazaarApplication, |
|
50 |
ICodehostingApplication, |
|
51 |
)
|
|
8590.2.2
by Tim Penhey
Fix the fallout in the zcml and other imports. |
52 |
from lp.code.interfaces.codeimportscheduler import ( |
11403.1.4
by Henning Eggers
Reformatted imports using format-imports script r32. |
53 |
ICodeImportSchedulerApplication, |
54 |
)
|
|
55 |
from lp.hardwaredb.interfaces.hwdb import ( |
|
11882.2.3
by Jonathan Lange
And that's the rest of them. |
56 |
IHWDBApplication, |
11403.1.4
by Henning Eggers
Reformatted imports using format-imports script r32. |
57 |
IHWDeviceSet, |
58 |
IHWDriverSet, |
|
59 |
IHWSubmissionDeviceSet, |
|
60 |
IHWSubmissionSet, |
|
61 |
IHWVendorIDSet, |
|
62 |
ParameterError, |
|
63 |
)
|
|
8590.2.2
by Tim Penhey
Fix the fallout in the zcml and other imports. |
64 |
from lp.registry.interfaces.distribution import IDistribution |
65 |
from lp.registry.interfaces.distributionsourcepackage import ( |
|
11403.1.4
by Henning Eggers
Reformatted imports using format-imports script r32. |
66 |
IDistributionSourcePackage, |
67 |
)
|
|
11882.2.3
by Jonathan Lange
And that's the rest of them. |
68 |
from lp.registry.interfaces.distroseries import IDistroSeriesSet |
14550.1.1
by Steve Kowalik
Run format-imports over lib/lp and lib/canonical/launchpad |
69 |
from lp.registry.interfaces.mailinglist import IMailingListApplication |
11882.2.3
by Jonathan Lange
And that's the rest of them. |
70 |
from lp.registry.interfaces.product import ( |
71 |
IProduct, |
|
72 |
IProductSet, |
|
73 |
)
|
|
14560.2.20
by Curtis Hovey
Moved IFeedsApplication to lp.services.feeds. |
74 |
from lp.services.feeds.interfaces import IFeedsApplication |
14578.3.1
by William Grant
Extract all the authserver stuff to lp.services.authserver. |
75 |
from lp.services.statistics.interfaces.statistic import ILaunchpadStatisticSet |
14560.2.24
by Curtis Hovey
Moved IWebServiceApplication to lp.services.webservice. |
76 |
from lp.services.webservice.interfaces import IWebServiceApplication |
11882.2.3
by Jonathan Lange
And that's the rest of them. |
77 |
from lp.services.worlddata.interfaces.language import ILanguageSet |
11403.1.4
by Henning Eggers
Reformatted imports using format-imports script r32. |
78 |
from lp.testopenid.interfaces.server import ITestOpenIDApplication |
14578.3.1
by William Grant
Extract all the authserver stuff to lp.services.authserver. |
79 |
from lp.translations.interfaces.translationgroup import ITranslationGroupSet |
14560.2.17
by Curtis Hovey
Moved IRosettaApplication to lp.translations. |
80 |
from lp.translations.interfaces.translations import IRosettaApplication |
11403.1.4
by Henning Eggers
Reformatted imports using format-imports script r32. |
81 |
from lp.translations.interfaces.translationsoverview import ( |
82 |
ITranslationsOverview, |
|
83 |
)
|
|
3617.1.2
by Steve Alexander
removed lib/canonical/rosetta, and changed _clearCache to the public API clear_current_connection_cache |
84 |
|
6275.4.4
by Gavin Panella
Move the IBug collection stuff away from the explicit adaptor to annotations on IMaloneApplication. |
85 |
|
9590.1.48
by Michael Hudson
a start at combining the puller and filesystem endpoints |
86 |
class CodehostingApplication: |
87 |
"""Codehosting End-Point."""
|
|
88 |
implements(ICodehostingApplication) |
|
89 |
||
90 |
title = "Codehosting API" |
|
6789.8.8
by Michael Hudson
puller_api -> branch_puller per review |
91 |
|
92 |
||
5354.1.3
by Michael Hudson
make the test pass |
93 |
class CodeImportSchedulerApplication: |
94 |
"""CodeImportScheduler End-Point."""
|
|
95 |
implements(ICodeImportSchedulerApplication) |
|
96 |
||
97 |
title = "Code Import Scheduler" |
|
98 |
||
99 |
||
6002.3.11
by Graham Binns
Renamed IExternalBugTrackerTokenApplication to IPrivateMaloneApplication. |
100 |
class PrivateMaloneApplication: |
6002.3.9
by Graham Binns
Made the private XML-RPC endpoint use its own ILaunchpadApplication subclass instead of IMaloneApplication. |
101 |
"""ExternalBugTracker authentication token end-point."""
|
6002.3.11
by Graham Binns
Renamed IExternalBugTrackerTokenApplication to IPrivateMaloneApplication. |
102 |
implements(IPrivateMaloneApplication) |
6002.3.9
by Graham Binns
Made the private XML-RPC endpoint use its own ILaunchpadApplication subclass instead of IMaloneApplication. |
103 |
|
6002.3.14
by Graham Binns
Review fixes for bac. |
104 |
title = "Launchpad Bugs." |
6002.3.9
by Graham Binns
Made the private XML-RPC endpoint use its own ILaunchpadApplication subclass instead of IMaloneApplication. |
105 |
|
106 |
||
4483.4.4
by Barry Warsaw
Flesh out the XMLRPC implementation of IRequestedMailingListAPI, along with |
107 |
class MailingListApplication: |
4823.6.6
by Barry Warsaw
As per Steve's recommendation, move the 'mailinglists' end point to |
108 |
implements(IMailingListApplication) |
4483.4.4
by Barry Warsaw
Flesh out the XMLRPC implementation of IRequestedMailingListAPI, along with |
109 |
|
5062.2.2
by Brad Crittenden
Changes due to review. |
110 |
|
4934.3.9
by Elliot Murphy
Renaming from Feed to Feeds. |
111 |
class FeedsApplication: |
112 |
implements(IFeedsApplication) |
|
4483.4.4
by Barry Warsaw
Flesh out the XMLRPC implementation of IRequestedMailingListAPI, along with |
113 |
|
5062.2.2
by Brad Crittenden
Changes due to review. |
114 |
|
6666.2.28
by Tom Berger
malone application home does not provide IHasBugs |
115 |
class MaloneApplication: |
1862
by Canonical.com Patch Queue Manager
bunch more [trivial] cleanup of stuff from canonical/thing putting stuff in better places. |
116 |
implements(IMaloneApplication) |
117 |
||
118 |
def __init__(self): |
|
2900.2.6
by Matthew Paul Thomas
fix menu item capitalization (and HTML error in front page) |
119 |
self.title = 'Malone: the Launchpad bug tracker' |
1862
by Canonical.com Patch Queue Manager
bunch more [trivial] cleanup of stuff from canonical/thing putting stuff in better places. |
120 |
|
11847.3.7
by Abel Deuring
added missing parameter prejoins to MaloneApplication.searchTasks() |
121 |
def searchTasks(self, search_params, prejoins=[]): |
7182.3.3
by Gary Poster
make changes per review by gmb |
122 |
"""See `IMaloneApplication`."""
|
11847.3.7
by Abel Deuring
added missing parameter prejoins to MaloneApplication.searchTasks() |
123 |
return getUtility(IBugTaskSet).search( |
124 |
search_params, prejoins=prejoins) |
|
3811.2.3
by Bjorn Tillenius
initial go at making the search on the Bugs front page work. |
125 |
|
6774.1.3
by Guilherme Salgado
Export a createBug operation on the bugs collection. |
126 |
def createBug(self, owner, title, description, target, |
127 |
security_related=False, private=False, tags=None): |
|
7182.3.3
by Gary Poster
make changes per review by gmb |
128 |
"""See `IMaloneApplication`."""
|
6774.1.3
by Guilherme Salgado
Export a createBug operation on the bugs collection. |
129 |
params = CreateBugParams( |
130 |
title=title, comment=description, owner=owner, |
|
131 |
security_related=security_related, private=private, tags=tags) |
|
132 |
if IProduct.providedBy(target): |
|
133 |
params.setBugTarget(product=target) |
|
134 |
elif IDistribution.providedBy(target): |
|
135 |
params.setBugTarget(distribution=target) |
|
136 |
elif IDistributionSourcePackage.providedBy(target): |
|
137 |
params.setBugTarget(distribution=target.distribution, |
|
138 |
sourcepackagename=target.sourcepackagename) |
|
139 |
else: |
|
140 |
raise InvalidBugTargetType( |
|
141 |
"A bug target must be a Project, a Distribution or a "
|
|
142 |
"DistributionSourcePackage. Got %r." % target) |
|
143 |
return getUtility(IBugSet).createBug(params) |
|
144 |
||
2048
by Canonical.com Patch Queue Manager
debbugssync, hct enabling, and ui fixes. r=jamesh |
145 |
@property
|
146 |
def bug_count(self): |
|
2489
by Canonical.com Patch Queue Manager
[r=kiko] Fix a bug on the Malone front page where 'latest bugs' wasn't |
147 |
user = getUtility(ILaunchBag).user |
148 |
return getUtility(IBugSet).searchAsUser(user=user).count() |
|
2048
by Canonical.com Patch Queue Manager
debbugssync, hct enabling, and ui fixes. r=jamesh |
149 |
|
150 |
@property
|
|
151 |
def bugwatch_count(self): |
|
2458
by Canonical.com Patch Queue Manager
[r=kiko] remove more dirty database imports |
152 |
return getUtility(IBugWatchSet).search().count() |
2048
by Canonical.com Patch Queue Manager
debbugssync, hct enabling, and ui fixes. r=jamesh |
153 |
|
154 |
@property
|
|
155 |
def bugtask_count(self): |
|
2458
by Canonical.com Patch Queue Manager
[r=kiko] remove more dirty database imports |
156 |
user = getUtility(ILaunchBag).user |
157 |
search_params = BugTaskSearchParams(user=user) |
|
158 |
return getUtility(IBugTaskSet).search(search_params).count() |
|
2048
by Canonical.com Patch Queue Manager
debbugssync, hct enabling, and ui fixes. r=jamesh |
159 |
|
160 |
@property
|
|
161 |
def bugtracker_count(self): |
|
7675.604.1
by Gavin Panella
Rename BugTrackerSet.bugtracker_count to just count. |
162 |
return getUtility(IBugTrackerSet).count |
2048
by Canonical.com Patch Queue Manager
debbugssync, hct enabling, and ui fixes. r=jamesh |
163 |
|
164 |
@property
|
|
3847.2.60
by Mark Shuttleworth
Show more interesting Malone stats |
165 |
def projects_with_bugs_count(self): |
166 |
return getUtility(ILaunchpadStatisticSet).value('projects_with_bugs') |
|
167 |
||
168 |
@property
|
|
169 |
def shared_bug_count(self): |
|
170 |
return getUtility(ILaunchpadStatisticSet).value('shared_bug_count') |
|
171 |
||
172 |
@property
|
|
2048
by Canonical.com Patch Queue Manager
debbugssync, hct enabling, and ui fixes. r=jamesh |
173 |
def top_bugtrackers(self): |
2908.2.2
by Brad Bollenbach
fixes based on code review |
174 |
return getUtility(IBugTrackerSet).getMostActiveBugTrackers(limit=5) |
1862
by Canonical.com Patch Queue Manager
bunch more [trivial] cleanup of stuff from canonical/thing putting stuff in better places. |
175 |
|
2450
by Canonical.com Patch Queue Manager
[r=jamesh] rework cve structure, and general polish |
176 |
@property
|
177 |
def latest_bugs(self): |
|
2489
by Canonical.com Patch Queue Manager
[r=kiko] Fix a bug on the Malone front page where 'latest bugs' wasn't |
178 |
user = getUtility(ILaunchBag).user |
179 |
return getUtility(IBugSet).searchAsUser( |
|
10287.2.1
by Graham Binns
Applied the patch to change the ordering from two columns to one. |
180 |
user=user, orderBy=['-datecreated'], limit=5) |
2450
by Canonical.com Patch Queue Manager
[r=jamesh] rework cve structure, and general polish |
181 |
|
6415.2.2
by Tom Berger
changes following a review by francis |
182 |
def default_bug_list(self, user=None): |
183 |
return getUtility(IBugSet).searchAsUser(user) |
|
6275.4.4
by Gavin Panella
Move the IBug collection stuff away from the explicit adaptor to annotations on IMaloneApplication. |
184 |
|
2450
by Canonical.com Patch Queue Manager
[r=jamesh] rework cve structure, and general polish |
185 |
|
1862
by Canonical.com Patch Queue Manager
bunch more [trivial] cleanup of stuff from canonical/thing putting stuff in better places. |
186 |
class BazaarApplication: |
187 |
implements(IBazaarApplication) |
|
188 |
||
189 |
def __init__(self): |
|
190 |
self.title = 'The Open Source Bazaar' |
|
3311.1.4
by Mark Shuttleworth
Polish up branch listings |
191 |
|
192 |
||
3617.1.2
by Steve Alexander
removed lib/canonical/rosetta, and changed _clearCache to the public API clear_current_connection_cache |
193 |
class RosettaApplication: |
194 |
implements(IRosettaApplication) |
|
195 |
||
196 |
def __init__(self): |
|
197 |
self.title = 'Rosetta: Translations in the Launchpad' |
|
198 |
self.name = 'Rosetta' |
|
199 |
||
200 |
@property
|
|
3691.8.65
by Carlos Perello Marin
Moved Translation groups pages to top translations.launchpad.net url and use the right page templates for it |
201 |
def languages(self): |
7182.3.3
by Gary Poster
make changes per review by gmb |
202 |
"""See `IRosettaApplication`."""
|
3691.8.65
by Carlos Perello Marin
Moved Translation groups pages to top translations.launchpad.net url and use the right page templates for it |
203 |
return getUtility(ILanguageSet) |
204 |
||
205 |
@property
|
|
206 |
def language_count(self): |
|
7182.3.3
by Gary Poster
make changes per review by gmb |
207 |
"""See `IRosettaApplication`."""
|
3691.8.65
by Carlos Perello Marin
Moved Translation groups pages to top translations.launchpad.net url and use the right page templates for it |
208 |
stats = getUtility(ILaunchpadStatisticSet) |
209 |
return stats.value('language_count') |
|
210 |
||
211 |
@property
|
|
3617.1.2
by Steve Alexander
removed lib/canonical/rosetta, and changed _clearCache to the public API clear_current_connection_cache |
212 |
def statsdate(self): |
213 |
stats = getUtility(ILaunchpadStatisticSet) |
|
214 |
return stats.dateupdated('potemplate_count') |
|
215 |
||
3691.8.65
by Carlos Perello Marin
Moved Translation groups pages to top translations.launchpad.net url and use the right page templates for it |
216 |
@property
|
217 |
def translation_groups(self): |
|
7182.3.3
by Gary Poster
make changes per review by gmb |
218 |
"""See `IRosettaApplication`."""
|
3691.8.65
by Carlos Perello Marin
Moved Translation groups pages to top translations.launchpad.net url and use the right page templates for it |
219 |
return getUtility(ITranslationGroupSet) |
220 |
||
3617.1.2
by Steve Alexander
removed lib/canonical/rosetta, and changed _clearCache to the public API clear_current_connection_cache |
221 |
def translatable_products(self): |
7182.3.3
by Gary Poster
make changes per review by gmb |
222 |
"""See `IRosettaApplication`."""
|
3617.1.2
by Steve Alexander
removed lib/canonical/rosetta, and changed _clearCache to the public API clear_current_connection_cache |
223 |
products = getUtility(IProductSet) |
3755.5.12
by Danilo Å egan
Clean-up test and everything. |
224 |
return products.getTranslatables() |
3755.5.4
by Danilo Å egan
Add page with all translatable products. |
225 |
|
226 |
def featured_products(self): |
|
7182.3.3
by Gary Poster
make changes per review by gmb |
227 |
"""See `IRosettaApplication`."""
|
5685.2.1
by Danilo Å egan
Basic project cloud for the translations frontpage. |
228 |
projects = getUtility(ITranslationsOverview) |
5685.2.3
by Danilo Å egan
Final style fixes. |
229 |
for project in projects.getMostTranslatedPillars(): |
11847.3.7
by Abel Deuring
added missing parameter prejoins to MaloneApplication.searchTasks() |
230 |
yield { |
231 |
'pillar': project['pillar'], |
|
232 |
'font_size': project['weight'] * 10, |
|
233 |
}
|
|
3617.1.2
by Steve Alexander
removed lib/canonical/rosetta, and changed _clearCache to the public API clear_current_connection_cache |
234 |
|
4285.2.1
by Mark Shuttleworth
Massive renaming of distrorelease to distroseries |
235 |
def translatable_distroseriess(self): |
7182.3.3
by Gary Poster
make changes per review by gmb |
236 |
"""See `IRosettaApplication`."""
|
4285.2.1
by Mark Shuttleworth
Massive renaming of distrorelease to distroseries |
237 |
distroseriess = getUtility(IDistroSeriesSet) |
238 |
return distroseriess.translatables() |
|
3617.1.2
by Steve Alexander
removed lib/canonical/rosetta, and changed _clearCache to the public API clear_current_connection_cache |
239 |
|
240 |
def potemplate_count(self): |
|
7182.3.3
by Gary Poster
make changes per review by gmb |
241 |
"""See `IRosettaApplication`."""
|
3617.1.2
by Steve Alexander
removed lib/canonical/rosetta, and changed _clearCache to the public API clear_current_connection_cache |
242 |
stats = getUtility(ILaunchpadStatisticSet) |
243 |
return stats.value('potemplate_count') |
|
244 |
||
245 |
def pofile_count(self): |
|
7182.3.3
by Gary Poster
make changes per review by gmb |
246 |
"""See `IRosettaApplication`."""
|
3617.1.2
by Steve Alexander
removed lib/canonical/rosetta, and changed _clearCache to the public API clear_current_connection_cache |
247 |
stats = getUtility(ILaunchpadStatisticSet) |
248 |
return stats.value('pofile_count') |
|
249 |
||
250 |
def pomsgid_count(self): |
|
7182.3.3
by Gary Poster
make changes per review by gmb |
251 |
"""See `IRosettaApplication`."""
|
3617.1.2
by Steve Alexander
removed lib/canonical/rosetta, and changed _clearCache to the public API clear_current_connection_cache |
252 |
stats = getUtility(ILaunchpadStatisticSet) |
253 |
return stats.value('pomsgid_count') |
|
254 |
||
255 |
def translator_count(self): |
|
7182.3.3
by Gary Poster
make changes per review by gmb |
256 |
"""See `IRosettaApplication`."""
|
3617.1.2
by Steve Alexander
removed lib/canonical/rosetta, and changed _clearCache to the public API clear_current_connection_cache |
257 |
stats = getUtility(ILaunchpadStatisticSet) |
258 |
return stats.value('translator_count') |
|
259 |
||
260 |
||
4675.3.1
by Abel Deuring
HWDB data upload form added |
261 |
class HWDBApplication: |
7353.2.1
by Abel Deuring
Webservice API for IHWDevice |
262 |
"""See `IHWDBApplication`."""
|
8805.9.4
by Abel Deuring
fix for access problem to the webservice root: IHWDBApplication no longer inherits from ITopLevelEntryLink |
263 |
implements(IHWDBApplication, ITopLevelEntryLink) |
5435.1.6
by Leonard Richardson
Implement a 'hello world' web service. |
264 |
|
7353.2.1
by Abel Deuring
Webservice API for IHWDevice |
265 |
link_name = 'hwdb' |
266 |
entry_type = IHWDBApplication |
|
267 |
||
268 |
def devices(self, bus, vendor_id, product_id=None): |
|
269 |
"""See `IHWDBApplication`."""
|
|
270 |
return getUtility(IHWDeviceSet).search(bus, vendor_id, product_id) |
|
271 |
||
7353.2.3
by Abel Deuring
Webservice API for table HWDriver |
272 |
def drivers(self, package_name=None, name=None): |
273 |
"""See `IHWDBApplication`."""
|
|
274 |
return getUtility(IHWDriverSet).search(package_name, name) |
|
275 |
||
7553.1.1
by Abel Deuring
webservice API for IHWVendorID |
276 |
def vendorIDs(self, bus): |
277 |
"""See `IHWDBApplication`."""
|
|
278 |
return getUtility(IHWVendorIDSet).idsForBus(bus) |
|
279 |
||
7745.1.1
by Abel Deuring
property HWDriverSet.package_names added and exposed to the webservice API |
280 |
@property
|
8538.3.1
by Abel Deuring
Python classes for SQL views hwdrivername and hwdriverpackagename added |
281 |
def driver_names(self): |
282 |
"""See `IHWDBApplication`."""
|
|
8538.3.2
by Abel Deuring
implemented reviewer's comments |
283 |
return getUtility(IHWDriverSet).all_driver_names() |
8538.3.1
by Abel Deuring
Python classes for SQL views hwdrivername and hwdriverpackagename added |
284 |
|
285 |
@property
|
|
7745.1.1
by Abel Deuring
property HWDriverSet.package_names added and exposed to the webservice API |
286 |
def package_names(self): |
287 |
"""See `IHWDBApplication`."""
|
|
8538.3.2
by Abel Deuring
implemented reviewer's comments |
288 |
return getUtility(IHWDriverSet).all_package_names() |
7745.1.1
by Abel Deuring
property HWDriverSet.package_names added and exposed to the webservice API |
289 |
|
13165.3.1
by Marc Tardif
Exposed the search method from IHWSubmissionSet in IHWDBApplication. |
290 |
def search(self, user=None, device=None, driver=None, distribution=None, |
13165.3.2
by Marc Tardif
Extended the search method from IHWSubmissionSet to filter before date created, after date created, before date submitted and after date submitted. |
291 |
distroseries=None, architecture=None, owner=None, |
292 |
created_before=None, created_after=None, |
|
293 |
submitted_before=None, submitted_after=None): |
|
13165.3.1
by Marc Tardif
Exposed the search method from IHWSubmissionSet in IHWDBApplication. |
294 |
"""See `IHWDBApplication`."""
|
295 |
return getUtility(IHWSubmissionSet).search( |
|
296 |
user=user, device=device, driver=driver, |
|
297 |
distribution=distribution, distroseries=distroseries, |
|
13165.3.2
by Marc Tardif
Extended the search method from IHWSubmissionSet to filter before date created, after date created, before date submitted and after date submitted. |
298 |
architecture=architecture, owner=owner, |
299 |
created_before=created_before, created_after=created_after, |
|
300 |
submitted_before=submitted_before, |
|
301 |
submitted_after=submitted_after) |
|
13165.3.1
by Marc Tardif
Exposed the search method from IHWSubmissionSet in IHWDBApplication. |
302 |
|
8366.1.2
by Abel Deuring
statistical methods for the HWDB exposed to the webservice API |
303 |
def getDistroTarget(self, distribution, distroseries, distroarchseries): |
304 |
distro_targets = [ |
|
305 |
target for target in ( |
|
306 |
distribution, distroseries, distroarchseries) |
|
307 |
if target is not None] |
|
308 |
if len(distro_targets) == 0: |
|
309 |
return None |
|
310 |
elif len(distro_targets) == 1: |
|
311 |
return distro_targets[0] |
|
312 |
else: |
|
313 |
raise ParameterError( |
|
314 |
'Only one of `distribution`, `distroseries` or '
|
|
315 |
'`distroarchseries` can be present.') |
|
316 |
||
317 |
def numSubmissionsWithDevice( |
|
8697.19.1
by Abel Deuring
allow driver-only queries for HWDB statistics methods. |
318 |
self, bus=None, vendor_id=None, product_id=None, driver_name=None, |
319 |
package_name=None, distribution=None, distroseries=None, |
|
320 |
distroarchseries=None): |
|
8366.1.2
by Abel Deuring
statistical methods for the HWDB exposed to the webservice API |
321 |
"""See `IHWDBApplication`."""
|
8366.1.3
by Abel Deuring
implemented reviewr's comments |
322 |
submissions_with_device, all_submissions = ( |
323 |
getUtility(IHWSubmissionSet).numSubmissionsWithDevice( |
|
324 |
bus, vendor_id, product_id, driver_name, package_name, |
|
325 |
distro_target=self.getDistroTarget( |
|
326 |
distribution, distroseries, distroarchseries))) |
|
327 |
return { |
|
328 |
'submissions_with_device': submissions_with_device, |
|
329 |
'all_submissions': all_submissions, |
|
330 |
}
|
|
8366.1.2
by Abel Deuring
statistical methods for the HWDB exposed to the webservice API |
331 |
|
332 |
def numOwnersOfDevice( |
|
8697.19.1
by Abel Deuring
allow driver-only queries for HWDB statistics methods. |
333 |
self, bus=None, vendor_id=None, product_id=None, driver_name=None, |
334 |
package_name=None, distribution=None, distroseries=None, |
|
335 |
distroarchseries=None): |
|
8366.1.2
by Abel Deuring
statistical methods for the HWDB exposed to the webservice API |
336 |
"""See `IHWDBApplication`."""
|
8366.1.3
by Abel Deuring
implemented reviewr's comments |
337 |
owners, all_submitters = ( |
338 |
getUtility(IHWSubmissionSet).numOwnersOfDevice( |
|
339 |
bus, vendor_id, product_id, driver_name, package_name, |
|
340 |
distro_target=self.getDistroTarget( |
|
341 |
distribution, distroseries, distroarchseries))) |
|
342 |
return { |
|
343 |
'owners': owners, |
|
344 |
'all_submitters': all_submitters, |
|
345 |
}
|
|
8366.1.2
by Abel Deuring
statistical methods for the HWDB exposed to the webservice API |
346 |
|
347 |
def numDevicesInSubmissions( |
|
8697.19.1
by Abel Deuring
allow driver-only queries for HWDB statistics methods. |
348 |
self, bus=None, vendor_id=None, product_id=None, driver_name=None, |
349 |
package_name=None, distribution=None, distroseries=None, |
|
350 |
distroarchseries=None): |
|
8366.1.2
by Abel Deuring
statistical methods for the HWDB exposed to the webservice API |
351 |
"""See `IHWDBApplication`."""
|
352 |
return getUtility(IHWSubmissionDeviceSet).numDevicesInSubmissions( |
|
8366.1.3
by Abel Deuring
implemented reviewr's comments |
353 |
bus, vendor_id, product_id, driver_name, package_name, |
354 |
distro_target=self.getDistroTarget( |
|
355 |
distribution, distroseries, distroarchseries)) |
|
8366.1.2
by Abel Deuring
statistical methods for the HWDB exposed to the webservice API |
356 |
|
8451.2.2
by Abel Deuring
allow to call deviceDriverOwnersAffectedByBugs only with a driver |
357 |
def deviceDriverOwnersAffectedByBugs( |
358 |
self, bus=None, vendor_id=None, product_id=None, driver_name=None, |
|
359 |
package_name=None, bug_ids=None, bug_tags=None, affected_by_bug=False, |
|
8451.2.1
by Abel Deuring
Method added to retrieve a list of device owners who are affected by bugs |
360 |
subscribed_to_bug=False, user=None): |
361 |
"""See `IHWDBApplication`."""
|
|
8451.2.2
by Abel Deuring
allow to call deviceDriverOwnersAffectedByBugs only with a driver |
362 |
return getUtility(IHWSubmissionSet).deviceDriverOwnersAffectedByBugs( |
8451.2.1
by Abel Deuring
Method added to retrieve a list of device owners who are affected by bugs |
363 |
bus, vendor_id, product_id, driver_name, package_name, bug_ids, |
364 |
bug_tags, affected_by_bug, subscribed_to_bug, user) |
|
365 |
||
8451.4.2
by Deryck Hodge
Change the method name. |
366 |
def hwInfoByBugRelatedUsers( |
8451.4.1
by Deryck Hodge
Enabling deviceDriversByOwner for HWSubmissionSet and the |
367 |
self, bug_ids=None, bug_tags=None, affected_by_bug=False, |
368 |
subscribed_to_bug=False, user=None): |
|
369 |
"""See `IHWDBApplication`."""
|
|
8451.4.2
by Deryck Hodge
Change the method name. |
370 |
return getUtility(IHWSubmissionSet).hwInfoByBugRelatedUsers( |
8451.4.1
by Deryck Hodge
Enabling deviceDriversByOwner for HWSubmissionSet and the |
371 |
bug_ids, bug_tags, affected_by_bug, subscribed_to_bug, user) |
372 |
||
5435.1.6
by Leonard Richardson
Implement a 'hello world' web service. |
373 |
|
5435.1.38
by Leonard Richardson
Integrated ServiceRoot with ServiceRootResource. |
374 |
class WebServiceApplication(ServiceRootResource): |
7182.3.3
by Gary Poster
make changes per review by gmb |
375 |
"""See `IWebServiceApplication`.
|
7182.3.2
by Gary Poster
change code to keep launchpad code in launchpad, not lazr; add tests. Once (or if) lint is happy, this should be ready for review. |
376 |
|
10420.4.1
by Leonard Richardson
Initial implementation. |
377 |
This implementation adds a 'cached_wadl' attribute, which starts
|
378 |
out as an empty dict and is populated as needed.
|
|
7182.3.2
by Gary Poster
change code to keep launchpad code in launchpad, not lazr; add tests. Once (or if) lint is happy, this should be ready for review. |
379 |
"""
|
7872.2.2
by Leonard Richardson
Removed canonical_url from everywhere except webservice.txt. |
380 |
implements(IWebServiceApplication, ICanonicalUrlData) |
381 |
||
382 |
inside = None |
|
383 |
path = '' |
|
384 |
rootsite = None |
|
7182.3.2
by Gary Poster
change code to keep launchpad code in launchpad, not lazr; add tests. Once (or if) lint is happy, this should be ready for review. |
385 |
|
10420.4.1
by Leonard Richardson
Initial implementation. |
386 |
cached_wadl = {} |
7182.3.2
by Gary Poster
change code to keep launchpad code in launchpad, not lazr; add tests. Once (or if) lint is happy, this should be ready for review. |
387 |
|
13289.2.1
by Gary Poster
make changes so that the wadl can be served directly from Apache. |
388 |
# This should only be used by devel instances: production serves root
|
389 |
# WADL (and JSON) from the filesystem.
|
|
390 |
||
10604.7.1
by Leonard Richardson
Restored the launchpadlib pagetest code. |
391 |
@classmethod
|
392 |
def cachedWADLPath(cls, instance_name, version): |
|
393 |
"""Helper method to calculate the path to a cached WADL file."""
|
|
394 |
return os.path.join( |
|
14600.1.14
by Curtis Hovey
Fixed path to locate the caches wadl. |
395 |
config.root, 'lib', 'canonical', 'launchpad', |
13289.2.1
by Gary Poster
make changes so that the wadl can be served directly from Apache. |
396 |
'apidoc', version, '%s.wadl' % (instance_name,)) |
10604.7.1
by Leonard Richardson
Restored the launchpadlib pagetest code. |
397 |
|
7182.3.2
by Gary Poster
change code to keep launchpad code in launchpad, not lazr; add tests. Once (or if) lint is happy, this should be ready for review. |
398 |
def toWADL(self): |
10420.4.1
by Leonard Richardson
Initial implementation. |
399 |
"""See `IWebServiceApplication`.
|
400 |
||
401 |
Look for a cached WADL file for the request version at the
|
|
402 |
location used by the script
|
|
403 |
utilities/create-launchpad-wadl.py. If the file is present,
|
|
404 |
load the file and cache its contents rather than generating
|
|
405 |
new WADL. Otherwise, generate new WADL and cache it.
|
|
406 |
"""
|
|
407 |
version = self.request.version |
|
408 |
if self.__class__.cached_wadl is None: |
|
409 |
# The cache has been disabled for testing
|
|
410 |
# purposes. Generate the WADL.
|
|
411 |
return super(WebServiceApplication, self).toWADL() |
|
412 |
if version not in self.__class__.cached_wadl: |
|
413 |
# It's not cached. Look for it on disk.
|
|
10604.7.1
by Leonard Richardson
Restored the launchpadlib pagetest code. |
414 |
_wadl_filename = self.cachedWADLPath( |
415 |
config.instance_name, version) |
|
10420.4.1
by Leonard Richardson
Initial implementation. |
416 |
_wadl_fd = None |
417 |
try: |
|
418 |
_wadl_fd = codecs.open(_wadl_filename, encoding='UTF-8') |
|
419 |
try: |
|
420 |
wadl = _wadl_fd.read() |
|
421 |
finally: |
|
422 |
_wadl_fd.close() |
|
423 |
except IOError: |
|
424 |
# It's not on disk; generate it.
|
|
425 |
wadl = super(WebServiceApplication, self).toWADL() |
|
426 |
del _wadl_fd |
|
427 |
self.__class__.cached_wadl[version] = wadl |
|
428 |
return self.__class__.cached_wadl[version] |
|
10065.2.3
by Guilherme Salgado
Move the test openid views under a newly created testopenid vhost. |
429 |
|
430 |
||
431 |
class TestOpenIDApplication: |
|
432 |
implements(ITestOpenIDApplication) |
|
11073.1.6
by Guilherme Salgado
Fix the IAbsoluteURL issue |
433 |
|
434 |
||
435 |
class APIDocRoot: |
|
436 |
implements(IAPIDocRoot) |
|
437 |
__parent__ = None |
|
438 |
__name__ = None |
|
439 |
||
440 |
apidocroot = APIDocRoot() |