TurboGears 1.x is using the Buffet API, and we're facing one serious
problem here when making the switch to Genshi, namely that it's
impossible to produce different doctype on different pages, e.g. when
you have part of your application that uses HTML, and a different part
that uses XHTML, or some pages using framesets or quirks mode.
The problem is that the doctype can only be passed to the buffet plugin
as an option at startup time, but at render time you can't overwrite
options any more, you can only overwrite the "format" (which corresponds
to Genshi's "method" parameter). If you set up the plugin with "html" as
the default method, and a html doctype, though you can later render
templates with an "xhtml" method, they still get the wrong html doctype.
We did not have this problem with Kid, since you can pass a doctype by
specifying e.g. "html-frameset", or "xhtml-strict" as the Buffet format
parameter; the format name in Kid always indirectly determines the
doctype as well. In Genshi however, you can only pass "html" or "xhtml"
here, and the doctype is chosen separately beforehand.
Also, in Kid you can pass serializer instances in the Buffet format
parameter, which have a suiting doctype already set, but in Genshi, you
can pass only serializer *classes* which are later initialized with the
default doctype that the plugin has been initialized with.
Here are some ideas how this problem could be solved in Genshi:
1) Let all serializer classes have their own default doctypes which will
be used when initialized with no doctype or an incompatible doctype.
2) Allow not only the names 'html', 'xhtml', 'xml', 'text' as rendering
methods, but also all names of doctypes such as 'html-transitional',
'html-frameset' etc. to specify method plus doctype in one parameter.
3) Add a parameter "options" to the Buffet API render method allowing to
overwrite any default parameters (particularly, the doctype parameter)
at rendering time.
Let me know how you think about this or if there are any better ideas.
-- Christoph
Perhaps I am missing or misunderstanding something, but I am using this:
self.stream.render('xhtml', doctype=DocType.XHTML_STRICT)
with Geshi which allows me to precisely specify which doctype of XHTML I
want.
--
Jeroen Ruigrok van der Werven <asmodai(-at-)in-nomine.org> / asmodai
イェルーン ラウフロック ヴァン デル ウェルヴェン
http://www.in-nomine.org/ | http://www.rangaku.org/ | GPG: 2EAC625B
He who knows, does not speak. He who speaks, does not know...
That's right, this is no problem if you're using Genshi directly. But
I'm talking about using Genshi via the Genshi Buffet interface (as used
by e.g. TurboGears 1.x). There is currently no way of passing in the
doctype parameter via Buffet at render time.
-- Christoph