Count results per item
======================

When searching with faceted navigation some widgets have ability to dynamicaly
update and display results per page.

Imports
-------

    >>> from zope.component import getMultiAdapter

Set up
------

Setup sandbox

    >>> portal = layer["portal"]
    >>> request = layer['request']
    >>> sandbox = portal['sandbox']
    >>> sandbox.setTitle('Faceted navigation counter test')

    >>> subtyper = getMultiAdapter((sandbox, request), name=u'faceted_subtyper')
    >>> subtyper.enable()

    >>> view    = sandbox.unrestrictedTraverse('@@facetednavigation_view')
    >>> handler = sandbox.unrestrictedTraverse('@@faceted_configure')
    >>> counter = sandbox.unrestrictedTraverse('@@faceted_counter')

    >>> default = [widget for widget in view.get_widgets()]
    >>> cids = [widget.data.getId() for widget in default]
    >>> _ = handler(deleteWidgets_button='Delete', paths=cids)

Alphabetic
----------
Calling counter for alphabetic widget will return a json object with all
starting letters as keys and number of results per each.

    >>> _ = handler(addPropertiesWidget_button='Add',
    ...         wtype='alphabetic', wposition='top', title='Alphabetic',
    ...         index='Title', default='A')
    >>> counter(cid='c0')
    '{..."W":...}'

Checkbox
--------
Counting on checkbox widget will return a json object with keys from
widget.vocabulary and number of cataloged objects per each

    >>> _ = handler(addPropertiesWidget_button='Add',
    ...         wtype='checkbox', wposition='left', title='Checkbox',
    ...         catalog='portal_catalog',
    ...         index='portal_type', default=[u'Folder'])
    >>> counter(cid='c1')
    '{..."Document": ...}'

Radio
-----
Same as for checkbox

    >>> _ = handler(addPropertiesWidget_button='Add',
    ...         wtype='radio', wposition='right', title='Radio',
    ...         catalog='portal_catalog',
    ...         index='portal_type')
    >>> counter(cid='c2')
    '{..."Document": ...}'

Select
------
Same as for checkbox.

    >>> _ = handler(addPropertiesWidget_button='Add',
    ...         wtype='select', wposition='center', title='Select',
    ...         catalog='portal_catalog',
    ...         index='portal_type')
    >>> counter(cid='c3')
    '{..."Document": ...}'
