14538.2.49
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).
|
6454.6.3
by Guilherme Salgado
Add ILaunchpadContext, to be implemented by things that can be used as context in OAuth tokens. |
3 |
|
6454.8.1
by Guilherme Salgado
Move the implementation of ILaunchpadContainer into adapters and create specific adapters for IBug and IBranch. |
4 |
"""ILaunchpadContainer adapters."""
|
5 |
||
6454.6.3
by Guilherme Salgado
Add ILaunchpadContext, to be implemented by things that can be used as context in OAuth tokens. |
6 |
__metaclass__ = type |
7 |
__all__ = [ |
|
6454.8.1
by Guilherme Salgado
Move the implementation of ILaunchpadContainer into adapters and create specific adapters for IBug and IBranch. |
8 |
'LaunchpadProductContainer', |
9 |
'LaunchpadDistributionSourcePackageContainer', |
|
6454.6.3
by Guilherme Salgado
Add ILaunchpadContext, to be implemented by things that can be used as context in OAuth tokens. |
10 |
]
|
11 |
||
6454.8.1
by Guilherme Salgado
Move the implementation of ILaunchpadContainer into adapters and create specific adapters for IBug and IBranch. |
12 |
|
13 |
from canonical.launchpad.webapp.publisher import LaunchpadContainer |
|
14 |
||
15 |
||
16 |
class LaunchpadProductContainer(LaunchpadContainer): |
|
17 |
||
18 |
def isWithin(self, scope): |
|
19 |
"""Is this product within the given scope?
|
|
20 |
||
21 |
A product is within itself or its project.
|
|
22 |
"""
|
|
23 |
||
24 |
return scope == self.context or scope == self.context.project |
|
25 |
||
26 |
||
27 |
class LaunchpadDistributionSourcePackageContainer(LaunchpadContainer): |
|
28 |
||
29 |
def isWithin(self, scope): |
|
30 |
"""Is this distribution source package within the given scope?
|
|
31 |
||
32 |
A distribution source package is within its distribution.
|
|
33 |
"""
|
|
34 |
return scope == self.context or scope == self.context.distribution |