Collection Filter Error

i have hundred of Words and i would like display a Collection of these words like Glossary. ABC... and so on
Ok all is fine, but the Letter "M" and "T" give me an error. All others are fine and displayed.
What i have done:

  1. I added an Index and a Metadata Column to Catalog.
  2. I wrote an Indexer
# -*- coding: utf8 -*-

def initialIndexer(obj):
    if obj.title is None:        
        return None
    title = obj.title
    initial = title[:1]
    if isinstance(initial, str):
        initial = initial.decode('utf8').upper()
    if str("Ä").decode("utf8") == initial:
        initial = u"A"
    elif str("Ö").decode("utf8") == initial:
        initial = u"O"
    elif str("Ü").decode("utf8") == initial:
        initial = u"U"
    return initial
  1. I register an Indexmodifier for in configure.zxml

  1. the modifier in
# -*- coding: utf8 -*-
from import IParsedQueryIndexModifier
from import base

class initial(base):
  1. I register a field for the Collection Edit View
        <value key="title" i18n:translate="">initial</value>
        <value key="description" i18n:translate="">The first initial Letter of Title</value>
        <value key="enabled">True</value>
        <value key="sortable">True</value>
        <value key="operations">
        <value key="group" i18n:translate="">Text</value>

Ok, and now i get the following Error/Traceback, only by the Letter "M" and "T":

Traceback (innermost last):
  Module ZPublisher.Publish, line 138, in publish
  Module ZPublisher.mapply, line 77, in mapply
  Module ZPublisher.Publish, line 48, in call_object
  Module, line 97, in html_results
  Module, line 88, in __call__
  Module, line 169, in _makequery
  Module Products.CMFPlone.CatalogTool, line 394, in searchResults
  Module Products.ZCatalog.ZCatalog, line 604, in searchResults
  Module Products.ZCatalog.Catalog, line 1072, in searchResults
  Module Products.ZCatalog.Catalog, line 549, in search
  Module Products.PluginIndexes.common.UnIndex, line 426, in _apply_index
TypeError: can't compare datetime.datetime to unicode

Are these forbidden characters? Why Datetime? I'm clueless.

The URL's of the query in the Editform of Collection

Here is all ok:

Here is the Error:


in plone/app/querystring/


(Pdb) pp parsedquery
  'initial': {'query': 'N'},
  'path': {'query': ['/lexikon/lexikon/']},
  'sort_limit': 10,
  'sort_on': 'sortable_title'


(Pdb) pp parsedquery
  'initial': {'query': datetime.datetime(2016, 6, 14, 0, 0)},
  'path': {'query': ['/lexikon/lexikon/']},
  'sort_limit': 10,
  'sort_on': 'sortable_title'

This observation indicates that for some reason, the "M" gave you a "DateTime" instead of the letter "M". Use the debugger to analyse earlier request processing to find out how this happened (it definitely looks very strange).

Can you try to clear and reindex the related index through the ZMI?


Yes, i have reindex the Catalog

The thing that bugs me about "initial" is that it's a name that could conceivably also be used to name an attribute that indicates a starting time. Just a random thought.

Ok, the Solution was a wrong indexmodifier. i took it from Subject Index Modifier and all was ok.


# -*- coding: utf8 -*-
from zope.interface import implementer
from import IParsedQueryIndexModifier


class Initial(object):
  def __call__(self, value):
     query = value['query']
    # query can be a unicode string
    if isinstance(query, unicode):
      query = query.encode("utf-8")
    value['query'] = query
    return ('initial', value)

Slightly off topic, but I have filtering on Creator and I just discovered that that it does not work for a Creator that has 'ø' in his name. (everything else works).

Making a new indexer for Creator and decode as you did could be a solution, or what do you think ?