can't set XUL content-type
Bug #98395 reported by
Roman Joost
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Zope 3 |
Won't Fix
|
Medium
|
Unassigned | ||
zope.publisher |
Fix Released
|
Medium
|
Justin Alan Ryan |
Bug Description
I'm currently trying to create a skin which generates XUL. Problem is, that Mozilla based browsers accept the content-type 'application/
This is an edge-case, but the code fragment at line 851 in zope.publisher.
Related branches
Changed in zope.publisher: | |
importance: | Undecided → Medium |
Changed in zope3: | |
status: | New → Won't Fix |
tags: | added: bugday20100424 |
Changed in zope.publisher: | |
assignee: | nobody → Justin Ryan (justizin) |
Changed in zope.publisher: | |
status: | New → In Progress |
To post a comment you must log in.
You can do something like this in your view code:
class MyView( BrowserPage) : eFile(' myxul.pt' )
self.request. response. setHeader( 'Content- Type', 'application/ vnd.mozilla. xul+xml' ) ).encode( 'UTF-8' )
template = ViewPageTemplat
def __call__(self):
return self.template(
In general, how can the Zope publisher figure out the byte encoding for your Unicode string for arbitrary content types? It could try to guess UTF-8 (or ISO-8859- 1/US-ASCII) , but what if it guesses wrong? Currently the publisher knows that if you have a text/something content type, the MIME standards allow a 'charset' parameter, so the publisher is free to choose any charset (and it chooses UTF-8) and modify the content type header to reflect the choice. In all other cases it is up to the view to convert Unicode text into the appropriate 8-bit encoding and return a str instead of unicode.
We could do a better job documenting this, as this issue is not the first question I've seen about people struggling with Unicode strings and non-text/* content types.
I suppose you could teach the publisher about a few other content types that aren't text/something but deliver Unicode text in some character set. application/ something+ xml comes into mind. I do not know enough about these content types to champion a proposal.
So, does anybody have a concrete proposal of what should be done to improve the situation, or should this issue be resolved as "not a bug"?