Warning: Can't synchronize with repository "(default)" (Unsupported version control system "svn": No module named svn). Look in the Trac log for more information.

Ticket #1918 (closed enhancement: worksforme)

Opened 11 years ago

Last modified 11 years ago

genshi.outputformat="xhtml" is ignored

Reported by: ondrejj Owned by: anonymous
Priority: normal Milestone:
Component: TurboGears Version: trunk
Severity: normal Keywords:
Cc:

Description

I think it's not possible to set genshi.outputformat to xhtml in TG2. In TG1 there was ability to set default output format for kid, but it's missing in TG2.

Can you please add this? I want to generate valid XHTML code and genshi convert's all my code to default outputformat, which is HTML.

My content is replaced for example from "<br/>" to "<br>", which is later validated by firefox's validator as wrong page. :(

I think there is same problem for all template systems, genshi, kid, mako, ...

Change History

comment:1 Changed 11 years ago by ondrejj

In genshi this parameter is default_format:

 http://genshi.edgewall.org/wiki/Documentation/0.5.x/plugin.html#genshi-default-format

Just I don't know, how to set it in TG2. Setting in app_cfg.py raises attribute error, setting in development.ini is ignored.

After some experiencing TG2, render_genshi function uses pylons render_genshi function, which has by default method="xhtml" set. But it can be overwritten with kwargs, I just can't find, where this function is called and who giges him method='html'.

comment:2 Changed 11 years ago by mramm

  • Milestone set to 1.9.7a4

comment:3 Changed 11 years ago by ondrejj

I have TurboGears2-1.9.7a4, but still don't know, how to set xhtml format. Is there some documentation or can you write here some examples?

comment:4 Changed 11 years ago by mramm

  • Milestone changed from 1.9.7a4 to 1.9.7b1

Are you using the default renderer, if so you're still using buffet, so you need to look at the setup in pylons 0.9.6. You can turn on the other renderers by switching them on in app_config.py. The renderer is picked out of a dictionary in config, and that dictionary is setup by the setup_mako_renderer method on the AppConfig? object, so you can overide it there.

But it seems like it would be worth making the format a configuration option.... I'll look into this no matter what, but if someone gives us a patch it'll get done quicker ;)

comment:5 Changed 11 years ago by ondrejj

I can't find, where "HTML" (non XHTML) is set. I see only, that in setup_genshi_renderer is used this:

from tg.render import render_genshi

And in tg.render:

def render_genshi(template_name, template_vars, **kwargs):
    """Render a the template_vars with the Genshi template"""
    template_vars['XML'] = XML
    return templating.render_genshi(template_name, extra_vars=template_vars, **kwargs)

And finally in pylons.templating:

def render_genshi(template_name, extra_vars=None, cache_key=None,
             cache_type=None, cache_expire=None, method='xhtml'):

But here is set method to xhtml, so why this does not work? Why my pages are encoded to HTML?

Also this code has no effect (config/app_cfg.py):

from pylons import templating
from genshi import XML

def render_genshi_sal(template_name, template_vars, **kwargs):
    """Render a the template_vars with the Genshi template""" 
    template_vars['XML'] = XML
    return templating.render_genshi(template_name, extra_vars=template_vars,
                                    method='xhtml-strict',
                                    **kwargs)

class AppConfig_updated(AppConfig):
  def setup_genshi_renderer(self): 
      super(AppConfig_updated, self).setup_genshi_renderer()
      self.render_functions.genshi = render_genshi_sal

base_config = AppConfig_updated()
base_config.renderers = []
base_config.default_renderer = 'genshi'
base_config.renderers.append('genshi') 

Can you help me, what's wrong?

comment:6 Changed 11 years ago by mramm

  • Status changed from new to closed
  • Resolution set to worksforme

his works when you use the new renderers, and we need to switch to that as the default in 2.0b1, and are just waiting on ticket #1942.

comment:7 Changed 11 years ago by anonymous

  • Milestone 1.9.7b1 deleted

Milestone 1.9.7b1 deleted

Note: See TracTickets for help on using tickets.