Metadata-Version: 1.0
Name: zeam.utils.batch
Version: 0.4
Summary: Generic Batch support for Zope
Home-page: UNKNOWN
Author: Sylvain Viollon
Author-email: thefunny@gmail.com
License: BSD
Description: ================
        zeam.utils.batch
        ================
        
        This package provides a batch functionality for Zope 2, Zope 3 and Grok.
        
        .. contents::
        
        Example
        =======
        
        A very straightforward example. We need to define a context to work
        on::
        
        >>> import grokcore.view as grok
        >>> from persistent import Persistent
        >>> from zope.component import queryMultiAdapter
        >>> from zeam.utils.batch import batch
        >>> from zeam.utils.batch.interfaces import IBatching
        
        >>> class Content(Persistent):
        ...     pass
        
        
        And now, you can define a view which use a batch, and render it::
        
        >>> class MyViewClass(grok.View):
        ...     grok.context(Content)
        ...
        ...     def update(self):
        ...          fulllist = [1, 2, 3, 4, 5, 6, 7, 8, 9]
        ...          self.myitems = batch(
        ...                 fulllist , count=3, name='nbs', request=self.request)
        ...
        ...          self.batch = queryMultiAdapter(
        ...	              (self.context, self.myitems, self.request),
        ...          	      IBatching)()
        ...
        ...     template = grok.PageTemplate('''
        ...     <tal:navigation tal:replace="structure view/batch" />
        ...     <span tal:content="item" tal:repeat="item view/myitems" />
        ...     <tal:navigation tal:replace="structure view/batch" />
        ...     ''')
        
        And this work::
        
        >>> from grokcore.component import testing
        >>> testing.grok_component("view", MyViewClass)
        True
        
        >>> from zope.publisher.browser import TestRequest
        >>> request = TestRequest()
        
        >>> root = getRootFolder()
        >>> root['myObject'] = Content()
        >>> myobj = root['myObject']
        
        >>> view = queryMultiAdapter((myobj, request), name="myviewclass")
        >>> "batchNav" in view()
        True
        
        
        API
        ===
        
        ``batch``
        This object implement the batch.
        
        You create him by giving him a list of objects, and a request, a
        count of object (and potentially a name for your batch).
        
        Afterwards, you will have an iterable object, that you can access
        as a list as well, which gives you access to *only* the current
        object to work on for this page of the batch.
        
        You can get as well the number of pages of the batch, where you are
        and so on. Please refer to the interface, inside the package, for
        more information.
        
        You can render your batch by adapting your context, your batch
        object and request to an ``IBatching``. That will give you a piece
        of HTML to include on your view to control the batch.
        
        
        
        
        Changelog
        =========
        
        0.4 (2009/10/16)
        ----------------
        
        .. note::
        
        This release is incompatible with previous ones. You are recomanded
        to review and adapt your code in order to use it.
        
        * Added README.txt as a doctest [trollfot]
        * The rendering is made by a IPageTemplate component, not longer by
        the Batching itself. [trollfot]
        * We no longer use the IBatchedContent. It has been removed. [trollfot]
        * `zeam.utils.batch` is now fully grokked. [trollfot]
        * batchView has been renamed Batching. [trollfot]
        * You adapt the batch with the view on which you display the batch:
        its name will keep when generating links,
        * Batch can be *disabled* with a count of 0,
        * Add translations for french, english and dutch.
        
        0.3 (2008/10/18)
        ----------------
        
        * Fix and add tests,
        * Don't display batch navigation if everything fits on one page,
        * No more special links are generated for the first page of the batch.
        
        0.2
        ---
        
        * Initial release
        
        
Keywords: batch zope
Platform: UNKNOWN
Classifier: Framework :: Zope2
Classifier: Framework :: Zope3
Classifier: Programming Language :: Python
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: License :: OSI Approved :: BSD License
