Unicode support
===============
Support for NON-ASCII queries

Imports
-------
    >>> from zope.component import getMultiAdapter
    >>> from eea.facetednavigation.interfaces import ICriteria
    >>> from eea.facetednavigation.interfaces import IWidgetsInfo
    >>> from Products.CMFCore.utils import getToolByName

Set up
------

    >>> portal = layer["portal"]
    >>> request = layer['request']
    >>> sandbox = portal['sandbox']
    >>> subtyper = getMultiAdapter((sandbox, request), name=u'faceted_subtyper')
    >>> subtyper.can_enable()
    True

    >>> subtyper.enable()

Cleanup default widgets
-----------------------

    >>> cids = ICriteria(sandbox).keys()
    >>> for cid in cids:
    ...     ICriteria(sandbox).delete(cid)
    >>> ICriteria(sandbox).keys()
    []

Add some content
----------------

    >>> doc = portal.invokeFactory('News Item', 'non-ascii-folder', title='NON-ASCII Folder')
    >>> doc = portal._getOb(doc)
    >>> doc.setLanguage('en')
    >>> doc.setSubject(('étire',))
    >>> doc.reindexObject()

Let's do some search
--------------------

    >>> configure = getMultiAdapter((sandbox, request), name=u'faceted_configure')
    >>> query = getMultiAdapter((sandbox, request), name=u'faceted_query')
    >>> widgets = sandbox.unrestrictedTraverse('@@faceted_widgets')

Checkbox widget

  Hidden

    >>> _ = configure(addPropertiesWidget_button='Add', wtype='checkbox',
    ...               wposition='top', title='Checkbox', catalog='portal_catalog',
    ...               index='Subject', default=['étire'], hidden=True)
    >>> brains = query.query(batch=False)
    >>> for brain in brains:
    ...     print(brain.Title)
    NON-ASCII Folder

  Visible

    >>> _ = configure(updateCriterion_button='Save', cid='c0', hidden=False)
    >>> request.form['c0[]'] = ['étire']
    >>> brains = query.query(batch=False)
    >>> for brain in brains:
    ...     print(brain.Title)
    NON-ASCII Folder

  Render

    >>> print(widgets())
    <BLANKLINE>
    ...<legend>Checkbox</legend>
    ...
    ...<input type="checkbox"...
    ...

  Cleanup

    >>> ICriteria(sandbox).delete('c0')
    >>> del request.form['c0[]']


Radio widget

  Hidden

    >>> _ = configure(addPropertiesWidget_button='Add', wtype='radio',
    ...               wposition='top', title='Radio', catalog='portal_catalog',
    ...               index='Subject', default='étire', hidden=True)
    >>> brains = query.query(batch=False)
    >>> for brain in brains:
    ...     print(brain.Title)
    NON-ASCII Folder

  Visible

    >>> _ = configure(updateCriterion_button='Save', cid='c0', hidden=False)
    >>> brains = query.query(batch=False, c0='étire')
    >>> for brain in brains:
    ...     print(brain.Title)
    NON-ASCII Folder

  Render

    >>> print(widgets())
    <BLANKLINE>
    ...<legend>Radio</legend>
    ...
    ...<input type="radio"...
    ...

  Cleanup

    >>> ICriteria(sandbox).delete('c0')

Select widget

  Hidden

    >>> _ = configure(addPropertiesWidget_button='Add', wtype='select',
    ...               wposition='top', title='Select', catalog='portal_catalog',
    ...               index='Subject', default='étire', hidden=True)
    >>> brains = query.query(batch=False)
    >>> for brain in brains:
    ...     print(brain.Title)
    NON-ASCII Folder

  Visible

    >>> _ = configure(updateCriterion_button='Save', cid='c0', hidden=False)
    >>> brains = query.query(batch=False, c0='étire')
    >>> for brain in brains:
    ...     print(brain.Title)
    NON-ASCII Folder

  Render

    >>> print(widgets())
    <BLANKLINE>
    ...<legend>Select</legend>
    ...
    ...<option...
    ...

  Cleanup

    >>> ICriteria(sandbox).delete('c0')


TagsCloud widget

  Hidden

    >>> _ = configure(addPropertiesWidget_button='Add', wtype='tagscloud',
    ...               wposition='top', title='Tags', catalog='portal_catalog',
    ...               index='Subject', default='étire', hidden=True)
    >>> brains = query.query(batch=False)
    >>> for brain in brains:
    ...     print(brain.Title)
    NON-ASCII Folder

  Visible

    >>> _ = configure(updateCriterion_button='Save', cid='c0', hidden=False)
    >>> brains = query.query(batch=False, c0='étire')
    >>> for brain in brains:
    ...     print(brain.Title)
    NON-ASCII Folder

  Render

    >>> print(widgets())
    <BLANKLINE>
    ...<legend>Tags</legend>
    ...
    ...<li...
    ...

  Cleanup

    >>> ICriteria(sandbox).delete('c0')


Text widget

  Hidden

    >>> _ = configure(addPropertiesWidget_button='Add', wtype='text',
    ...               wposition='top', title='Text',
    ...               index='Subject', default='étire', hidden=True)
    >>> brains = query.query(batch=False)
    >>> for brain in brains:
    ...     print(brain.Title)
    NON-ASCII Folder

  Visible

    >>> _ = configure(updateCriterion_button='Save', cid='c0', hidden=False)
    >>> brains = query.query(batch=False, c0='étire')
    >>> for brain in brains:
    ...     print(brain.Title)
    NON-ASCII Folder

  Search in current results

    >>> brains = query.query(batch=False, c0=['étire'])
    >>> for brain in brains:
    ...     print(brain.Title)
    NON-ASCII Folder

  Render

    >>> print(widgets())
    <BLANKLINE>
    ...<legend>Text</legend>
    ...
    ...<input type="text"...
    ...

  Cleanup

    >>> ICriteria(sandbox).delete('c0')
