[Grok-dev] Re: grok.PageTemplate and content types

Philipp von Weitershausen philipp at weitershausen.de
Fri Jan 12 09:27:02 EST 2007


Jan-Wijbrand Kolman wrote:
> (ouch, I replied to Philipp initially, not to the list. Here is it again)
> 
>> >> We could make this quite explicit using the file extension, for
>> >> example. 'foo.pt' would be text/html and 'foo.xpt' would be text/xml.
>> >
>> > That's too big of a change;
> <snip>
> 
> I agree. Actually, I was wondering about the "dependency" on the *.pt
> extension altogether. But that's for some other time.
> 
>> > Is the sniffing too magic? Do people trip up because of this in Zope?
>>
>> Well, it used to be that you had to add the <?xml ?> processing
>> instruction to a template file to enforce the XML parser. This made it
>> pretty much impossible to use the XML parser for XHTML documents because
>> IE goes into quirks mode when it sees <?xml ?>.
> 
> Ah, good point, I didn't realise that...
> 
>> I'm pretty sure that zope.pagetemplate.pagetemplatefile still uses that
>> sniffing algorithm.
> 
> Yes it is.
> 
> What about begin able to do this:
> 
> class Foo(grok.View):
>     grok.template('specialfoo', mime_type='application/xml')
> 
> and
> 
> grok.PageTemplate("""\
>     <html>
>     ...
>     </html>
>     """, mime_type="application/xml")
> 
> Would that work?

Sure, that would work for me, except I'd suggest calling it content_type 
as that seem sto be used by zope.pagetemplate itself.

> We still need to find a reasonable default of course...

zope.pagetemplate.pagetemplate.PageTemplate seems to default to 
text/html. I'd be fine with that.

-- 
http://worldcookery.com -- Professional Zope documentation and training
2nd edition of Web Component Development with Zope 3 is now shipping!


More information about the Grok-dev mailing list