~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/canonical/launchpad/doc/navigation.txt

  • Committer: Steve Kowalik
  • Date: 2011-08-07 04:05:52 UTC
  • mto: This revision was merged to the branch mainline in revision 13626.
  • Revision ID: stevenk@ubuntu.com-20110807040552-mwnxo0flmhvl35e8
Correct the notification based on review comments, and remove request{,ed}
from the function names, switching to create{,d}.

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
 
lp.services.webapp.Navigation.
 
8
canonical.launchpad.webapp.Navigation.
9
9
 
10
 
    >>> from lp.services.webapp import Navigation
 
10
    >>> from canonical.launchpad.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 lp.services.webapp.servers
 
80
    >>> import canonical.launchpad.webapp.servers
81
81
 
82
 
    >>> class StepsToGo(lp.services.webapp.servers.StepsToGo):
 
82
    >>> class StepsToGo(canonical.launchpad.webapp.servers.StepsToGo):
83
83
    ...
84
84
    ...     def __init__(self, stack):
85
85
    ...         self.travstack = stack
241
241
    ...     def __call__(self):
242
242
    ...         return "a view on a thingset"
243
243
 
244
 
    >>> import lp.testing
245
 
    >>> lp.testing.ThingSetView = ThingSetView
246
 
    >>> lp.testing.ThingSetNavigation = ThingSetNavigation
247
 
    >>> lp.testing.IThingSet = IThingSet
 
244
    >>> import canonical.launchpad.ftests
 
245
    >>> canonical.launchpad.ftests.ThingSetView = ThingSetView
 
246
    >>> canonical.launchpad.ftests.ThingSetNavigation = ThingSetNavigation
 
247
    >>> canonical.launchpad.ftests.IThingSet = IThingSet
248
248
 
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="lp.services.webapp" file="meta.zcml" />
 
252
    ...   <include package="canonical.launchpad.webapp" file="meta.zcml" />
253
253
    ...   <include package="zope.app.zcmlfiles" file="meta.zcml" />
254
254
    ...   <browser:navigation
255
 
    ...       module="lp.testing"
 
255
    ...       module="canonical.launchpad.ftests"
256
256
    ...       classes="ThingSetNavigation"
257
257
    ...       />
258
258
    ...   <browser:page
259
 
    ...       for="lp.testing.IThingSet"
 
259
    ...       for="canonical.launchpad.ftests.IThingSet"
260
260
    ...       name="thingview"
261
 
    ...       class="lp.testing.ThingSetView"
 
261
    ...       class="canonical.launchpad.ftests.ThingSetView"
262
262
    ...       attribute="__call__"
263
263
    ...       permission="zope.Public"
264
264
    ...       layer="zope.publisher.interfaces.browser.IBrowserRequest"
270
270
 
271
271
    >>> from zope.component import getMultiAdapter
272
272
    >>> from zope.publisher.interfaces.browser import IBrowserPublisher
273
 
    >>> from lp.services.webapp.servers import LaunchpadTestRequest
 
273
    >>> from canonical.launchpad.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 lp.services.webapp import stepto
 
301
    >>> from canonical.launchpad.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 lp.services.webapp import stepthrough
 
353
    >>> from canonical.launchpad.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 lp.services.webapp import redirection
 
422
    >>> from canonical.launchpad.webapp import redirection
423
423
 
424
424
    >>> class ThingSetNavigation4(ThingSetNavigation):
425
425
    ...