[Grok-dev] Re: grok.PageTemplate and content types
Martijn Faassen
faassen at startifact.com
Fri Jan 12 10:27:29 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.
I have the idea to support other templating languages by allowing files
with other extensions in there, eventually.
>> > 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? We still need to find a reasonable default of course...
Do I understand it correctly that the goal here is to control the output
mime type? I wonder whether we don't simply want to support a
grok.mime_type directive on views (and your solution for the inline page
templates). Such a separate directive allows view subclassing and such,
which your grok.template doesn't support, I think.
Regards,
Martijn
More information about the Grok-dev
mailing list