[Grok-dev] Re: grok.PageTemplate and content types
faassen at startifact.com
Fri Jan 12 14:44:46 EST 2007
Philipp von Weitershausen wrote:
> No need for a mime type directive, you can always do
> response.setHeader('Content-Type', 'text/xml') from anywhere in your
> view. Or perhaps I'm misinterpreting what problem this grok.mime_type
> directive is supposed to solve.
No, I think you're right. I got side-tracked.
> To solve JW's problem, we really just need an explicit way to specify
> the parser type in ZPTs. I suggested file extensions, JW suggested a
> parameter when instantiating templates. I think a solution somewhere
> along or between those lines can be found.
Ah, I understood that before but then I got lost in all the discussion.
One of the interesting problems we have here is that we want to pass a
parameter *specific to the ZPT engine* along. So far Grok's template
story was more or less template-engine neutral and I'd like any changes
to keep it that way.
That would mean a 'mime_type' parameter to grok.template would be out.
Your proposal of specific file extensions works, but I still don't like
for other reasons.
I could imagine a grok.templating_parameters directive specifically to
control the behavior of a page template:
This directive would be special in that it would just stuff a lot of
stuff expected to be picked up by a template engine onto the view. For
ZPT that might be the parser option. It'd basically stuff in the **kw,
and the template engine part is responsible for reading it and doing
something with it (and perhaps give a GrokError if it can't be
This would be templating engine agnostic. If you put in a Genshi
template it'd be picked up by its file extension and you could pass it
I call this 'templating_parameters', which is verbose, and explicitly
not 'template_parameters', which is too ambiguous. This means it stands
out, which is fine in this case. Since it's a directive, it'll subclass,
so if you have a lot of templates that all need the XML parser for ZPT,
you could, if you wanted to, do this:
and just subclass it.
More information about the Grok-dev