'Converts Python values to a string for Whoosh.
Code courtesy of pysolr.'

def _from_python(self, value):

    if hasattr(value, u'strftime'):
        if (not hasattr(value, u'hour')):
            value = datetime(value.year, value.month, value.day, 0, 0, 0)
    elif isinstance(value, bool):
        if value:
            value = u'true'
        else:
            value = u'false'
    elif isinstance(value, (list, tuple)):
        value = u','.join([force_text(v) for v in value])
    elif isinstance(value, (six.integer_types, float)):
        pass
    else:
        value = force_text(value)
    return value
