~launchpad-pqm/launchpad/devel

8687.15.17 by Karl Fogel
Add the copyright header block to the rest of the files under lib/lp/.
1
# Copyright 2009 Canonical Ltd.  This software is licensed under the
2
# GNU Affero General Public License version 3 (see the file LICENSE).
2628 by Canonical.com Patch Queue Manager
[trivial] converted a bunch of browser:traverse into navigation
3
4
__metaclass__ = type
5
3147.5.59 by Celso Providelo
Improve and test IPackageRelationship features.
6
__all__ = [
7
    'BinaryPackageReleaseNavigation',
8
    'BinaryPackageView',
9
    ]
10
11
from apt_pkg import ParseDepends
12
11403.1.4 by Henning Eggers
Reformatted imports using format-imports script r32.
13
from canonical.launchpad.webapp import Navigation
13130.1.12 by Curtis Hovey
Sorted imports.
14
from lp.soyuz.browser.packagerelationship import relationship_builder
8294.6.1 by Julian Edwards
First stab at code-reorg. Still got a discrepancy on stuff I assigned to registry but not migrated yet.
15
from lp.soyuz.interfaces.binarypackagerelease import IBinaryPackageRelease
11403.1.4 by Henning Eggers
Reformatted imports using format-imports script r32.
16
2628 by Canonical.com Patch Queue Manager
[trivial] converted a bunch of browser:traverse into navigation
17
3111.1.4 by Diogo Matsubara
Fixes https://launchpad.net/products/soyuz/+bug/31158 (BinaryPackageRelease page is crashing because of portlet details)
18
class BinaryPackageReleaseNavigation(Navigation):
2628 by Canonical.com Patch Queue Manager
[trivial] converted a bunch of browser:traverse into navigation
19
    usedfor = IBinaryPackageRelease
3147.5.59 by Celso Providelo
Improve and test IPackageRelationship features.
20
21
22
class BinaryPackageView:
23
    """View class for BinaryPackage"""
24
25
    def __init__(self, context, request):
26
        self.context = context
27
        self.request = request
28
29
    def _relationship_parser(self, content):
30
        """Wrap the relationship_builder for BinaryPackages.
31
32
        Define apt_pkg.ParseDep as a relationship 'parser' and
4285.2.1 by Mark Shuttleworth
Massive renaming of distrorelease to distroseries
33
        IDistroArchSeries.getBinaryPackage as 'getter'.
3147.5.59 by Celso Providelo
Improve and test IPackageRelationship features.
34
        """
7675.687.103 by Michael Nelson
package-pages-navigation.txt
35
        getter = self.context.build.distro_arch_series.getBinaryPackage
3147.5.59 by Celso Providelo
Improve and test IPackageRelationship features.
36
        parser = ParseDepends
37
        return relationship_builder(content, parser=parser, getter=getter)
38
39
    def depends(self):
40
        return self._relationship_parser(self.context.depends)
41
42
    def recommends(self):
43
        return self._relationship_parser(self.context.recommends)
44
45
    def conflicts(self):
46
        return self._relationship_parser(self.context.conflicts)
47
48
    def replaces(self):
49
        return self._relationship_parser(self.context.replaces)
50
51
    def suggests(self):
52
        return self._relationship_parser(self.context.suggests)
53
54
    def provides(self):
55
        return self._relationship_parser(self.context.provides)
5226.1.19 by Celso Providelo
UI changes to present the new SPR/BPR fields (package relationships).
56
57
    def pre_depends(self):
58
        return self._relationship_parser(self.context.pre_depends)
59
60
    def enhances(self):
61
        return self._relationship_parser(self.context.enhances)
62
63
    def breaks(self):
64
        return self._relationship_parser(self.context.breaks)