[Grok-dev] grok.PageTemplate and content types

Gary Poster gary at zope.com
Thu Jan 11 09:18:46 EST 2007

On Jan 11, 2007, at 6:23 AM, Jan-Wijbrand Kolman wrote:

> Hi,
> grok.PageTemplate subclasses from
> zope.pagetemplate.pagetemplate.PageTemplate which by default treats
> the template's source as text/html. As a result the HTMLTALParser is
> used for compiling the template code, which can lead to problems if
> you want to use proper XML (like XHTML). For example, the
> HTMLTALParser does not allow for a closing </link> tag. Ugh.
> Anyway, zope.pagetemplate.pagetemplatefile.PageTemplateFile deals with
> this by sniffing the template's file contents to determine whether
> it's dealing with XML or not. If it is, it makes sure the content_type
> attr for the template instance is set to 'text/xml' and thus the
> 'TALParser' is used for compiling the template code,
> I can see two solutions:
> 1) Make use of zope.pagetemplate.pagetemplatefile.PageTemplateFile in
> grok.templatereg.TemplateRegistry if it is dealing with filesystem
> templates, or
> 2) Sniff the template content in grok.components.PageTemplate.__init__
> and to set the content_type attr on the instance accordingly.

3) make connecting templates more explicit :-D

Thanks for all the replies to the thread I started, btw; I  
particularly plan to reply to Martijn's thoughtful post ASAP.


More information about the Grok-dev mailing list