~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/lp/services/webapp/doc/navigation.txt

  • Committer: Curtis Hovey
  • Date: 2011-12-24 17:49:30 UTC
  • mto: This revision was merged to the branch mainline in revision 14602.
  • Revision ID: curtis.hovey@canonical.com-20111224174930-xk1d5cvhyxq46ctf
Moved webapp to lp.services.

Show diffs side-by-side

added added

removed removed

Lines of Context:
5
5
`canonical/launchpad/browser/`, alongside the view classes.
6
6
 
7
7
To define a navigation component, write a class that derives from
8
 
canonical.launchpad.webapp.Navigation.
 
8
lp.services.webapp.Navigation.
9
9
 
10
 
    >>> from canonical.launchpad.webapp import Navigation
 
10
    >>> from lp.services.webapp import Navigation
11
11
 
12
12
When you write a navigation class, you can talk about four kinds of traversal.
13
13
 
77
77
    ...         self.redirected_to = name
78
78
    ...         self.status = status
79
79
 
80
 
    >>> import canonical.launchpad.webapp.servers
 
80
    >>> import lp.services.webapp.servers
81
81
 
82
 
    >>> class StepsToGo(canonical.launchpad.webapp.servers.StepsToGo):
 
82
    >>> class StepsToGo(lp.services.webapp.servers.StepsToGo):
83
83
    ...
84
84
    ...     def __init__(self, stack):
85
85
    ...         self.travstack = stack
249
249
    >>> from zope.configuration import xmlconfig
250
250
    >>> zcmlcontext = xmlconfig.string("""
251
251
    ... <configure xmlns:browser="http://namespaces.zope.org/browser">
252
 
    ...   <include package="canonical.launchpad.webapp" file="meta.zcml" />
 
252
    ...   <include package="lp.services.webapp" file="meta.zcml" />
253
253
    ...   <include package="zope.app.zcmlfiles" file="meta.zcml" />
254
254
    ...   <browser:navigation
255
255
    ...       module="lp.testing"
270
270
 
271
271
    >>> from zope.component import getMultiAdapter
272
272
    >>> from zope.publisher.interfaces.browser import IBrowserPublisher
273
 
    >>> from canonical.launchpad.webapp.servers import LaunchpadTestRequest
 
273
    >>> from lp.services.webapp.servers import LaunchpadTestRequest
274
274
    >>> navigation = getMultiAdapter(
275
275
    ...     (thingset, LaunchpadTestRequest()), IBrowserPublisher, name='')
276
276
 
298
298
 
299
299
Let's create a subclass of ThingSetNavigation, and add a 'stepto'.
300
300
 
301
 
    >>> from canonical.launchpad.webapp import stepto
 
301
    >>> from lp.services.webapp import stepto
302
302
    >>> from lp.app.errors import NotFoundError
303
303
 
304
304
    >>> class ThingSetNavigation2(ThingSetNavigation):
350
350
 
351
351
Let's create another subclass and add a stepthrough.
352
352
 
353
 
    >>> from canonical.launchpad.webapp import stepthrough
 
353
    >>> from lp.services.webapp import stepthrough
354
354
 
355
355
    >>> class ThingSetNavigation3(ThingSetNavigation):
356
356
    ...
419
419
 
420
420
Let's make another navigation class to test redirection.
421
421
 
422
 
    >>> from canonical.launchpad.webapp import redirection
 
422
    >>> from lp.services.webapp import redirection
423
423
 
424
424
    >>> class ThingSetNavigation4(ThingSetNavigation):
425
425
    ...