~launchpad-pqm/launchpad/devel

13240.2.12 by Brad Crittenden
Mild code reorg. Test clean up.
1
# Copyright 2011 Canonical Ltd.  This software is licensed under the
2
# GNU Affero General Public License version 3 (see the file LICENSE).
3
4
"""Navigation views for processors."""
5
6
7
__metaclass__ = type
8
9
__all__ = [
10
    'ProcessorFamilySetNavigation',
13387.1.10 by Francis J. Lacoste
URL to processor is now of the form /+processors/<name>
11
    'ProcessorSetNavigation',
13240.2.12 by Brad Crittenden
Mild code reorg. Test clean up.
12
    ]
13
14
14600.2.2 by Curtis Hovey
Moved webapp to lp.services.
15
from lp.services.webapp import Navigation
13240.2.12 by Brad Crittenden
Mild code reorg. Test clean up.
16
from lp.app.errors import NotFoundError
17
from lp.soyuz.interfaces.processor import (
18
    IProcessorFamilySet,
13387.1.10 by Francis J. Lacoste
URL to processor is now of the form /+processors/<name>
19
    IProcessorSet,
13240.2.12 by Brad Crittenden
Mild code reorg. Test clean up.
20
    )
21
22
23
class ProcessorFamilySetNavigation(Navigation):
24
    """IProcessorFamilySet navigation."""
25
    usedfor = IProcessorFamilySet
26
27
    def traverse(self, name):
28
        family = self.context.getByName(name)
29
        # Raise NotFoundError on invalid processor family name.
30
        if family is None:
31
            raise NotFoundError(name)
32
        return family
33
34
13387.1.10 by Francis J. Lacoste
URL to processor is now of the form /+processors/<name>
35
class ProcessorSetNavigation(Navigation):
36
    """IProcessorFamilySet navigation."""
37
    usedfor = IProcessorSet
38
39
    def traverse(self, name):
40
        return self.context.getByName(name)