Text Widget
===========
Facet for free text search. This widget allows you to search by a free text
query or by multiple string queries.

Set up
------

  Imports

    >>> from zope.component import getMultiAdapter
    >>> from eea.facetednavigation.interfaces import ICriteria

  Add faceted navigable sandbox

    >>> portal = layer['portal']
    >>> request = layer['request']
    >>> sandbox = portal['sandbox']

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

    >>> subtyper.enable()

  Setup faceted components

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

  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='Distance-to-target (Kyoto Protocol) for new Member States countries')
    >>> doc = portal._getOb(doc)
    >>> doc.setLanguage('en')
    >>> doc.setSubject((u'\u015etire', u'\u015etire politica'))
    >>> doc.reindexObject()

    >>> doc = portal.invokeFactory('News Item', 'doc-title-two',
    ...         title='443/2009 EEA-32')
    >>> doc = portal._getOb(doc)
    >>> doc.setLanguage('en')
    >>> doc.reindexObject()

Faceted navigation
------------------

  Add a hidden Text facet and do some search

    >>> _ = configure(addPropertiesWidget_button='Add', wtype='text',
    ...               wposition='top', title='Text',
    ...               index='Subject', default=u'\u015etire', hidden=True)
    >>> brains = query.query(batch=False)
    >>> for brain in brains:
    ...     print(brain.Title)
    Distance-to-target (Kyoto Protocol) for new Member States countries

  Make it visible

    >>> _ = configure(updateCriterion_button='Save', cid='c0', hidden=False)
    >>> brains = query.query(batch=False, c0=u'\u015etire')
    >>> for brain in brains:
    ...     print(brain.Title)
    Distance-to-target (Kyoto Protocol) for new Member States countries

  As we said before, you can search using multiple queries. This is used in real
  world to search in current query

    >>> brains = query.query(batch=False, c0=[u'\u015etire', u'\u015etire politica'])
    >>> for brain in brains:
    ...     print(brain.Title)
    Distance-to-target (Kyoto Protocol) for new Member States countries

  Now let's do some search in title

    >>> _ = configure(updateCriterion_button='Save', cid='c0', index='Title')
    >>> brains = query.query(batch=False, c0='Kyoto')
    >>> for brain in brains:
    ...     print(brain.Title)
    Distance-to-target (Kyoto Protocol) for new Member States countries

    >>> brains = query.query(batch=False, c0='(Kyoto')
    >>> for brain in brains:
    ...     print(brain.Title)
    Distance-to-target (Kyoto Protocol) for new Member States countries

    >>> brains = query.query(batch=False, c0=['(Kyoto', 'Protocol)'])
    >>> for brain in brains:
    ...     print(brain.Title)
    Distance-to-target (Kyoto Protocol) for new Member States countries

    >>> brains = query.query(batch=False, c0=['Member States', 'Kyoto'])
    >>> for brain in brains:
    ...     print(brain.Title)
    Distance-to-target (Kyoto Protocol) for new Member States countries

    >>> brains = query.query(batch=False, c0='443/2009')
    >>> for brain in brains:
    ...     print(brain.Title)
    443/2009 EEA-32

    >>> brains = query.query(batch=False, c0=['443/2009'])
    >>> for brain in brains:
    ...     print(brain.Title)
    443/2009 EEA-32

    >>> brains = query.query(batch=False, c0='EEA-32')
    >>> for brain in brains:
    ...     print(brain.Title)
    443/2009 EEA-32

    >>> brains = query.query(batch=False, c0=['EEA-32'])
    >>> for brain in brains:
    ...     print(brain.Title)
    443/2009 EEA-32

    >>> brains = query.query(batch=False, c0=['(Kyoto', 'EEA-32'])
    >>> [brain.Title for brain in brains]
    []

  Wildcard search

    >>> brains = query.query(batch=False, c0=['Proto'])
    >>> [brain.Title for brain in brains]
    []
    >>> _ = configure(updateCriterion_button='Save', cid='c0', wildcard=1)
    >>> brains = query.query(batch=False, c0=['Proto'])
    >>> for brain in brains:
    ...     print(brain.Title)
    Distance-to-target (Kyoto Protocol) for new Member States countries

  Render facet

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

  Cleanup

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