14538.2.49
by Curtis Hovey
Updated copyright. |
1 |
# Copyright 2010-2011 Canonical Ltd. This software is licensed under the
|
11128.6.2
by Michael Hudson
move bugs publisher |
2 |
# GNU Affero General Public License version 3 (see the file LICENSE).
|
3 |
||
11128.6.14
by Michael Hudson
add tests for bugs and blueprints publication |
4 |
"""Bugs' custom publication."""
|
11128.6.2
by Michael Hudson
move bugs publisher |
5 |
|
6 |
__metaclass__ = type |
|
7 |
__all__ = [ |
|
8 |
'BugsBrowserRequest', |
|
9 |
'BugsLayer', |
|
10 |
'bugs_request_publication_factory', |
|
14538.2.9
by Curtis Hovey
Moved LaunchpadBugContainer to lp.bugs.publisher. |
11 |
'LaunchpadBugContainer', |
11128.6.2
by Michael Hudson
move bugs publisher |
12 |
]
|
13 |
||
14 |
||
15 |
from zope.interface import implements |
|
16 |
from zope.publisher.interfaces.browser import ( |
|
11403.1.4
by Henning Eggers
Reformatted imports using format-imports script r32. |
17 |
IBrowserRequest, |
18 |
IDefaultBrowserLayer, |
|
19 |
)
|
|
11128.6.2
by Michael Hudson
move bugs publisher |
20 |
|
14600.2.2
by Curtis Hovey
Moved webapp to lp.services. |
21 |
from lp.services.webapp.interfaces import ILaunchpadContainer |
22 |
from lp.services.webapp.publication import LaunchpadBrowserPublication |
|
23 |
from lp.services.webapp.publisher import LaunchpadContainer |
|
24 |
from lp.services.webapp.servers import ( |
|
11403.1.4
by Henning Eggers
Reformatted imports using format-imports script r32. |
25 |
LaunchpadBrowserRequest, |
26 |
VHostWebServiceRequestPublicationFactory, |
|
27 |
)
|
|
11128.6.2
by Michael Hudson
move bugs publisher |
28 |
|
29 |
||
30 |
class BugsLayer(IBrowserRequest, IDefaultBrowserLayer): |
|
31 |
"""The Bugs layer."""
|
|
32 |
||
33 |
||
11128.6.14
by Michael Hudson
add tests for bugs and blueprints publication |
34 |
class BugsBrowserRequest(LaunchpadBrowserRequest): |
35 |
"""Instances of BugBrowserRequest provide `BugsLayer`."""
|
|
11128.6.2
by Michael Hudson
move bugs publisher |
36 |
implements(BugsLayer) |
37 |
||
38 |
||
39 |
def bugs_request_publication_factory(): |
|
11128.6.14
by Michael Hudson
add tests for bugs and blueprints publication |
40 |
return VHostWebServiceRequestPublicationFactory( |
11128.6.2
by Michael Hudson
move bugs publisher |
41 |
'bugs', BugsBrowserRequest, LaunchpadBrowserPublication) |
14538.2.9
by Curtis Hovey
Moved LaunchpadBugContainer to lp.bugs.publisher. |
42 |
|
43 |
||
44 |
class LaunchpadBugContainer(LaunchpadContainer): |
|
45 |
||
46 |
def isWithin(self, scope): |
|
47 |
"""Is this bug within the given scope?
|
|
48 |
||
49 |
A bug is in the scope of any of its bugtasks' targets.
|
|
50 |
"""
|
|
51 |
for bugtask in self.context.bugtasks: |
|
52 |
if ILaunchpadContainer(bugtask.target).isWithin(scope): |
|
53 |
return True |
|
54 |
return False |