Ticket #1680: tg2-default-template-config.patch

File tg2-default-template-config.patch, 3.2 kB (added by lmacken, 5 months ago)

An updated patch that obsoletes all of the others in this ticket.

  • decorators/__init__.py

    old new  
    55needed to support these decorators.""" 
    66 
    77import formencode 
     8 
     9from pylons import config 
    810from paste.util.mimeparse import best_match 
    911 
    1012def _schema(d=None, **kw): 
     
    177179        elif ':' in template: 
    178180            engine, template = template.split(':', 1) 
    179181        elif template: 
    180             #TODO: lookup the default template engine from the config. 
    181             engine, template = 'genshi', template 
     182            engine = config['buffet.template_engines'][0]['engine'] 
    182183        else: 
    183184            engine, template = None, None 
    184185        if content_type is None: 
  • templates/turbogears/+package+/config/middleware.py_tmpl

    old new  
    1717 
    1818 
    1919from  ${package}.config.environment import load_environment 
    20 from  ${package}.controllers.root import RootController 
    2120 
    2221def make_app(global_conf, full_stack=True, **app_conf): 
    2322    """Create a Pylons WSGI application and return it 
     
    3938    """ 
    4039    # Configure the Pylons environment 
    4140    load_environment(global_conf, app_conf) 
     41 
     42    from  ${package}.controllers.root import RootController 
    4243     
    4344    # Create the TurboGears WSGI app stack 
    4445    app = PylonsApp() 
  • templates/turbogears/+package+/config/environment.py_tmpl

    old new  
    3838    config['routes.map'] = make_map()                 
    3939    config['pylons.app_globals'] = app_globals.Globals() 
    4040    config['pylons.app_globals'].sa_engine = engine_from_config(config, 'sqlalchemy.') 
    41      
     41 
     42 
     43    # If you'd like to change the default template engine used to render 
     44    # text/html content, edit these options. 
     45    template_engine = 'genshi' 
     46    template_engine_options = {} 
     47 
     48    config['buffet.template_engines'].pop() 
     49    config.add_template_engine(template_engine, '${package}.templates', 
     50                               template_engine_options) 
     51 
    4252    # Pass the engine to initmodel, to be able to introspect tables  
    4353    engine = engine_from_config(config, 'sqlalchemy.')  
    4454    init_model(engine)  
  • templates/turbogears/development.ini_tmpl

    old new  
    4343sqlalchemy.echo_pool = false 
    4444sqlalchemy.pool_recycle = 3600 
    4545 
    46 # If you'd like to change the default template engine used to render text/html 
    47 # content, edit this line.  
    48 template_engine.default = genshi 
    49  
    5046# WARNING: *THE LINE BELOW MUST BE UNCOMMENTED ON A PRODUCTION ENVIRONMENT* 
    5147# Debug mode will enable the interactive debugging tool, allowing ANYONE to 
    5248# execute malicious code after an exception is raised.