[Zope3-Users] Creating XML using Pagetemplates doesn't work

Stephan Richter srichter at cosmos.phy.tufts.edu
Mon Mar 20 09:22:53 EST 2006


On Wednesday 01 March 2006 11:22, Frank Burkhardt wrote:
> Hi,
>
> I wrote a view that returns a Atom-document (comparable to RSS). The
> content type is 'application/atom+xml'. Unfortunately the pagetemplate
> inserts some strings containing german umlauts (non-ascii) and I
> get this error:

Honestly, the content type declaration sucks, but I know, you cannot do 
anything about that. :-(

> ValueError: Unicode results must have a text content type.
>
> I found this line in zope.publisher.http:
>
>  if not content_type.startswith('text/'):
>   raise ValueError(
>   [...]
>
> which explains everything.

Yep.

> I tried to insert the umlauts in HTML notation (e.g. 'ü') but
> zope outsmarted me and escaped the '&' :-( .
>
> My Question is: What is the best way (tm) to handle that?

There are two solutions to the problem:

1. Write your own request/response object; I think someone has done that 
already.

2. Instead of returning a string, return an IResult object. Then the indicated 
piece of code will be ignored.

Regards,
Stephan
-- 
Stephan Richter
CBU Physics & Chemistry (B.S.) / Tufts Physics (Ph.D. student)
Web2k - Web Software Design, Development and Training


More information about the Zope3-users mailing list