I am trying to make my content object IExternallyEditable, and I ran up
against the following code in
zope.publisher.http.HTTPResult._implicitResult (line 849ff)::
if isinstance(body, unicode):
if not content_type.startswith('text/'):
'Unicode results must have a text content type,'
'got %s.' % content_type)
'Unicode results must have a text content type.')
(note: the first raise originally did not give the feedback about the
received content type.)
And my question is: Why? (do unicode results need to have a text/* type)
The traceback I get in the ErrorReportingUtility is::
Traceback (most recent call last):
Module zope.publisher.publish, line 136, in publish
Module zope.publisher.http, line 811, in setResult
body, headers = self._implicitResult(result)
Module zope.publisher.browser, line 686, in _implicitResult
body, headers = super(BrowserResponse, self)._implicitResult(body)
Module zope.publisher.http, line 851, in _implicitResult
ValueError: Unicode results must have a text content type,got
The reason AFAICT is that my content object just stores its source as
unicode object and simply provides that in its IReadFile adapter.
This turns the whole response/result in the ExternalEditor browser view
into a unicode object,
and finally the httpresult refuses to deal with it.
One workaround I see is to (utf8-)encode the data in my IReadFile adapter.
But for a text/* content type the httpresult would nicely determine a
charset from the request parameters (and using IUserPreferredCharsets).
I would like to just use that.
Am I missing something?
Zope3-users mailing list