~launchpad-pqm/launchpad/devel

8687.15.22 by Karl Fogel
Add the copyright header block to the remaining .py files.
1
# Copyright 2009 Canonical Ltd.  This software is licensed under the
2
# GNU Affero General Public License version 3 (see the file LICENSE).
8485.4.2 by Celso Providelo
adding Packageset navigation class.
3
4
"""Browser views for packagesets."""
5
6
__metaclass__ = type
7
8
__all__ = [
9
    'PackagesetSetNavigation',
10
    ]
11
12
14600.2.2 by Curtis Hovey
Moved webapp to lp.services.
13
from lp.services.webapp import GetitemNavigation
8485.4.2 by Celso Providelo
adding Packageset navigation class.
14
from lp.soyuz.interfaces.packageset import IPackagesetSet
15
16
17
class PackagesetSetNavigation(GetitemNavigation):
18
    """Navigation methods for PackagesetSet."""
19
    usedfor = IPackagesetSet
7675.361.1 by Muharem Hrnjadovic
Imported code from previous branch.
20
7675.361.2 by Muharem Hrnjadovic
Revised package set traversal/navigation scheme to take into account the new distro series association (with a big THANK YOU to Michael Nelson).
21
    def traverse(self, distroseries):
7675.361.5 by Muharem Hrnjadovic
Abel's review comments.
22
        """Traverse package sets in distro series context.
23
24
        The URI fragment of interest is:
25
26
            /package-sets/lucid/mozilla
27
28
        where 'lucid' is the distro series and 'mozilla' is the package set
29
        *name* respectively.
30
        """
7675.361.2 by Muharem Hrnjadovic
Revised package set traversal/navigation scheme to take into account the new distro series association (with a big THANK YOU to Michael Nelson).
31
        if self.request.stepstogo:
32
            # The package set name follows after the distro series.
33
            ps_name = self.request.stepstogo.consume()
34
            return self.context.getByName(ps_name, distroseries=distroseries)
35
36
        # Otherwise return None (to trigger a NotFound error).
37
        return None
38