#1963: Pages of quickstarted TG 1.1 app do not validate
-------------------------+--------------------------------------------------
Reporter: chrisz | Owner: Chris Arndt
Type: defect | Status: assigned
Priority: high | Milestone: 1.1
Component: TurboGears | Version: 1.1 HEAD
Severity: major | Resolution:
Keywords: needs tests |
-------------------------+--------------------------------------------------
Comment (by chrisz):
I've now tested passing an initialized serializer object, but
unfortunately it doesn't work, because Genshi tries to initialize it again
with the default doctype.
So this is another reason for implementing one or two of 1) - 3).
Implementing 1) is most simple, since it is already half-way implemented
by the 'mapping' parameter, as you already mentioned.
We would only need to add `mapping` as an optional parameter to the render
method of the Genshi buffet plugin like this:
{{{
def render(self, info, format=None, fragment=False, template=None,
mapping=None):
"""Render the template to a string using the provided info."""
kwargs = self._get_render_options(format=format,
fragment=fragment)
if mapping:
kwargs.update(mapping)
return self.transform(info, template).render(**kwargs)
}}}
You can then write
{{{
@expose(template="...", mapping=dict(doctype='html-transitional'))
}}}
We should consider two tweaks here:
* Rename `mapping` to `options` since then it's more clear that it will
be used for template options. Renaming will not be a problem because it
never worked anyway, since no template engine ever supported a `mapping`
parameter and it was never documented for the Buffet interface.
* If we want to keep the signature of the `render` method, we could add
another method `render_with_options` that is called by view.render if
there are options. But maybe this only complicates things.
* Instead of a single parameter `mapping` receiving a dict, we could use
keyword parameters of the form ``**mapping``, in the expose decorator
and/or in the render method. For the expose method, this would require
some more tweaks in turbogears.controllers and view.base, but then you
could simply write:
{{{
@expose(template="...", doctype='html-transitional')
}}}
Nice, but I'm not sure if this would be too large a change.
--
Ticket URL: <http://trac.turbogears.org/ticket/1963#comment:25>
TurboGears <http://www.turbogears.org/>
TurboGears front-to-back web development
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "TurboGears Tickets" group.
This group is read-only. No posting by normal members allowed.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/turbogears-tickets?hl=en?hl=en
-~----------~----~----~----~------~----~------~--~---