~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/lp/app/doc/batch-navigation.txt

  • Committer: Launchpad Patch Queue Manager
  • Date: 2011-12-22 04:45:35 UTC
  • mfrom: (14565.2.24 apocalyptic-pieces)
  • Revision ID: launchpad@pqm.canonical.com-20111222044535-jbjyzq3hzwiy7g20
[rs=sinzui][no-qa] Move javascript and scripts to lp. Dismantle
 mailnotification.

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
 
25
25
Imports:
26
26
 
27
 
  >>> from canonical.launchpad.webapp.batching import BatchNavigator
28
 
  >>> from canonical.launchpad.webapp.servers import LaunchpadTestRequest
 
27
    >>> from canonical.launchpad.webapp.batching import BatchNavigator
 
28
    >>> from canonical.launchpad.webapp.servers import LaunchpadTestRequest
29
29
 
30
 
  >>> def build_request(query_string_args=None, method='GET'):
31
 
  ...   if query_string_args is None:
32
 
  ...       query_string = ''
33
 
  ...   else:
34
 
  ...       query_string = "&".join(
35
 
  ...           ["%s=%s" % (k,v) for k,v in query_string_args.items()])
36
 
  ...   request = LaunchpadTestRequest(SERVER_URL='http://www.example.com/foo',
37
 
  ...                                  method=method,
38
 
  ...                                  environ={'QUERY_STRING': query_string})
39
 
  ...   request.processInputs()
40
 
  ...   return request
 
30
    >>> def build_request(query_string_args=None, method='GET'):
 
31
    ...   if query_string_args is None:
 
32
    ...       query_string_args = {}
 
33
    ...   query_string = "&".join(
 
34
    ...       "%s=%s" % (k,v) for k,v in query_string_args.items())
 
35
    ...   request = LaunchpadTestRequest(
 
36
    ...       SERVER_URL='http://www.example.com/foo', method=method,
 
37
    ...       environ={'QUERY_STRING': query_string})
 
38
    ...   request.processInputs()
 
39
    ...   return request
41
40
 
42
41
A dummy request object:
43
42
 
44
43
Some sample data.
45
44
 
46
 
  >>> reindeer = ['Dasher', 'Dancer', 'Prancer', 'Vixen', 'Comet',
47
 
  ...     'Cupid', 'Donner', 'Blitzen', 'Rudolph']
 
45
    >>> reindeer = [
 
46
    ...     'Dasher', 'Dancer', 'Prancer', 'Vixen', 'Comet',
 
47
    ...     'Cupid', 'Donner', 'Blitzen', 'Rudolph',
 
48
    ...     ]
48
49
 
49
50
 
50
51
Multiple pages
58
59
    >>> batch_nav.has_multiple_pages
59
60
    True
60
61
 
61
 
    >>> one_page_nav = BatchNavigator(select_results, build_request(), size=200)
 
62
    >>> one_page_nav = BatchNavigator(
 
63
    ...     select_results, build_request(), size=200)
62
64
    >>> one_page_nav.has_multiple_pages
63
65
    False
64
66