~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/canonical/lazr/testing/menus.py

  • Committer: William Grant
  • Date: 2011-12-30 02:21:12 UTC
  • mto: (14606.3.6 apocaremains)
  • mto: This revision was merged to the branch mainline in revision 14608.
  • Revision ID: william.grant@canonical.com-20111230022112-1b1pdbwt1suongbu
Drop fatsam.dia. It's more than 6 years out of date.

Show diffs side-by-side

added added

removed removed

Lines of Context:
10
10
    ]
11
11
 
12
12
from lazr.restful.utils import safe_hasattr
13
 
from zope.security.management import (
14
 
    endInteraction,
15
 
    newInteraction,
16
 
    )
17
13
from zope.security.proxy import isinstance as zope_isinstance
 
14
from zope.security.management import endInteraction, newInteraction
18
15
 
19
16
from lp.services.webapp import urlsplit
20
17
from lp.services.webapp.interfaces import ILink
21
 
from lp.services.webapp.publisher import canonical_url
22
18
from lp.services.webapp.servers import LaunchpadTestRequest
23
19
 
24
20
 
25
 
def check_menu_links(menu):
26
 
    context = menu.context
27
 
    for link in menu.iterlinks():
28
 
        if link.target.startswith(('/', 'http://')):
29
 
            # The context is not the context of this target.
30
 
            continue
31
 
        if '?' in link.target:
32
 
            view_name, _args = link.target.split('?')
33
 
        else:
34
 
            view_name = link.target
35
 
        if view_name == '':
36
 
            view_name = None
37
 
        try:
38
 
            canonical_url(context, view_name=view_name, rootsite=link.site)
39
 
        except Exception:
40
 
            return 'Bad link %s: %s' % (link.name, canonical_url(context))
41
 
    return True
42
 
 
43
 
 
44
21
def summarise_tal_links(links):
45
22
    """List the links and their attributes in the dict or list.
46
23