Hi,
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:
- I added an Index and a Metadata Column to Catalog.
- I wrote an Indexer
# -*- coding: utf8 -*-
@indexer(IDocument)
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
- I register an Indexmodifier for plone.app.querystring in configure.zxml
<configure
xmlns="http://namespaces.zope.org/zope"
i18n_domain="plonetheme.lexikon">
<utility
factory=".query_index_modifiers.initial"
provides="plone.app.querystring.interfaces.IParsedQueryIndexModifier"
name="initial"
/>
</configure>
- the modifier in query_index_modifiers.py
# -*- coding: utf8 -*-
from plone.app.querystring.interfaces import IParsedQueryIndexModifier
from plone.app.querystring.indexmodifiers.query_index_modifiers import base
class initial(base):
pass
- I register a field for the Collection Edit View
<records
interface="plone.app.querystring.interfaces.IQueryField"
prefix="plone.app.querystring.field.initial">
<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">
<element>plone.app.querystring.operation.string.is</element>
</value>
<value key="group" i18n:translate="">Text</value>
</records>
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 plone.app.querystring.querybuilder, line 97, in html_results
Module plone.app.querystring.querybuilder, line 88, in __call__
Module plone.app.querystring.querybuilder, 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.
Postscript:
The URL's of the query in the Editform of Collection
Here is all ok:
/@@querybuilder_html_results?query.i:records=initial&query.o:records=plone.app.querystring.operation.string.is&query.v:records=A&sort_on=sortable_title
Here is the Error:
/@@querybuilder_html_results?query.i:records=initial&query.o:records=plone.app.querystring.operation.string.is&query.v:records=M&sort_on=sortable_title