ZTUtils.py :  » Web-Frameworks » Zope » Zope-2.6.0 » lib » python » Products » PageTemplates » help » Python Open Source

Home
Python Open Source
1.3.1.2 Python
2.Ajax
3.Aspect Oriented
4.Blog
5.Build
6.Business Application
7.Chart Report
8.Content Management Systems
9.Cryptographic
10.Database
11.Development
12.Editor
13.Email
14.ERP
15.Game 2D 3D
16.GIS
17.GUI
18.IDE
19.Installer
20.IRC
21.Issue Tracker
22.Language Interface
23.Log
24.Math
25.Media Sound Audio
26.Mobile
27.Network
28.Parser
29.PDF
30.Project Management
31.RSS
32.Search
33.Security
34.Template Engines
35.Test
36.UML
37.USB Serial
38.Web Frameworks
39.Web Server
40.Web Services
41.Web Unit
42.Wiki
43.Windows
44.XML
Python Open Source » Web Frameworks » Zope 
Zope » Zope 2.6.0 » lib » python » Products » PageTemplates » help » ZTUtils.py
"""
ZTUtils: Page Template Utilities

  The classes in this module are available from Page Templates.

"""

class Batch:
    """
    Batch - a section of a large sequence.

    You can use batches to break up large sequences (such as search
    results) over several pages.

    Batches provide Page Templates with similar functions as those
    built-in to '<dtml-in>'.

    You can access elements of a batch just as you access elements of
    a list. For example::

      >>> b=Batch(range(100), 10)
      >>> b[5]
      4
      >>> b[10]
      IndexError: list index out of range

    Batches have these public attributes:

    start -- The first element number (counting from 1).

    first -- The first element index (counting from 0). Note that this
    is that same as start - 1.

    end -- The last element number (counting from 1).

    orphan -- The desired minimum batch size. This controls how
    sequences are split into batches. If a batch smaller than the
    orphan size would occur, then no split is performed, and a batch
    larger than the batch size results.

    overlap -- The number of elements that overlap between batches.

    length -- The actual length of the batch. Note that this can be
    different than size due to orphan settings.

    size -- The desired size. Note that this can be different than the
    actual length of the batch due to orphan settings.

    previous -- The previous batch or None if this is the first batch.

    next -- The next batch or None if this is the last batch.
    """

    def __init__(self, sequence, size, start=0, end=0,
                 orphan=0, overlap=0):
        """
        Creates a new batch given a sequence and a desired batch
        size.

        sequence -- The full sequence.

        size -- The desired batch size.

        start -- The index of the start of the batch (counting from 0).

        end -- The index of the end of the batch (counting from  0).

        orphan -- The desired minimum batch size. This controls how
        sequences are split into batches. If a batch smaller than the
        orphan size would occur, then no split is performed, and a
        batch larger than the batch size results.

        overlap -- The number of elements that overlap between
        batches.
        """
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.