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

Philipp von Weitershausen philipp at weitershausen.de
Thu Jan 11 17:10:06 EST 2007

Martijn Faassen wrote:
> Philipp von Weitershausen wrote:
> [snip]
>> I already did this in grok svn, so that changes to filesystem ZPTs 
>> wouldn't require a Zope 3 restart.
>>> 2) Sniff the template content in grok.components.PageTemplate.__init__
>>> and to set the content_type attr on the instance accordingly.
>> 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; people would need to change their extensions 
> and rename lots of files just because they want to make their templates 
> XHMTL and add a bit to the header? I'd prefer to reserve different 
> extensions for different page template engines altogether.
> 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 ?>.

I'm pretty sure that zope.pagetemplate.pagetemplatefile still uses that 
sniffing algorithm. I, however, would certainly find the use of two 
different extensions more elegant than many things you could put inside 
the template. And it's not like we're introducing an inflation of file 
extensions. Just '.pt' and '.xpt' would be for ZPTs (and in a way, they 
would be two slightly different engines anyway, given that they'd 
enforce different parsers).

I don't claim to know much about this, so I'm not feeling strongly about 
anything. I'm sure the problem prevails in Zope 3, though, and perhaps 
we should fix it there first.

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