Changeset 4687

Show
Ignore:
Timestamp:
06/08/08 10:00:47 (6 months ago)
Author:
mramm
Message:

Template fixed for non-identity SQLAlchemy projects.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • projects/tg.devtools/trunk/devtools/templates/turbogears/+package+/config/environment.py_tmpl

    r4657 r4687  
    1010{{endif}} 
    1111from pylons import config 
    12  
    1312from pylons.i18n import ugettext 
    1413from genshi.filters import Translator 
    1514from tg import defaults 
     15from tg.render import render_json, render_genshi, render_mako 
    1616 
    1717{{if sqlalchemy}} 
     
    2323#from {{package}}.config.routing import make_map 
    2424{{if sqlalchemy}} 
    25 from {{package}}.model import init_model, DBSession, metadata, User, Group, Permission 
     25from {{package}}.model import init_model, DBSession, metadata 
    2626{{endif}} 
     27{{if identity=='sqlalchemy'}}  
     28{{package}}.model import User, Group, Permission 
     29{{endif}} 
     30 
     31 
    2732 
    2833{{if template_engine == 'genshi'}} 
     
    6671                      } 
    6772     
    68  
    6973    {{endif}} 
    7074     
    71     {{if template_engine == 'mako'}} 
    72     # Create the Mako TemplateLookup, with the default auto-escaping 
    73     config['pylons.app_globals'].mako_lookup = TemplateLookup( 
    74         directories=paths['templates'], 
    75         module_directory=os.path.join(app_conf['cache_dir'], 'templates'), 
    76         input_encoding='utf-8', output_encoding='utf-8', 
    77         imports=['from webhelpers.html import escape'], 
    78         default_filters=['escape']) 
    79     {{elif template_engine == 'genshi'}} 
    80      
    81     # Create the Genshi TemplateLoader 
    82     config['pylons.app_globals'].genshi_loader = TemplateLoader( 
    83         paths['templates'], auto_reload=True) 
    84     {{elif template_engine == 'jinja'}} 
    85  
    86     # Create the Jinja Environment 
    87     config['pylons.app_globals'].jinja_env = Environment(loader=ChoiceLoader( 
    88             [FileSystemLoader(path) for path in paths['templates']])) 
    89     # Jinja's unable to request c's attributes without strict_c 
    90     config['pylons.strict_c'] = True 
    91     {{endif}} 
    92  
    93     # If you'd like to change the default template engine used to render 
    94     # text/html content, edit these options. 
    95     default_template_engine = 'genshi' 
    96     default_template_engine_options = {} 
    97     config['buffet.template_engines'].pop() 
    98     config.add_template_engine(default_template_engine, '${package}.templates', 
    99                                default_template_engine_options) 
    100  
    10175    {{if sqlalchemy}}     
    10276    # Setup SQLAlchemy database engine 
     
    10983    {{endif}} 
    11084     
     85    # Template rendering setup: 
     86     
     87    {{if template_engine == 'mako'}} 
     88    # Create the Mako TemplateLookup, with the default auto-escaping 
     89    config['pylons.app_globals'].mako_lookup = TemplateLookup( 
     90        directories=paths['templates'], 
     91        module_directory=os.path.join(app_conf['cache_dir'], 'templates'), 
     92        input_encoding='utf-8', output_encoding='utf-8', 
     93        imports=['from webhelpers.html import escape'], 
     94        default_filters=['escape']) 
     95     
     96    config['tg.default_renderer'] = 'mako' 
     97         
     98    {{elif template_engine == 'genshi'}} 
     99    # Create the Genshi TemplateLoader 
     100    config['pylons.app_globals'].genshi_loader = TemplateLoader( 
     101        paths['templates'], auto_reload=True) 
     102     
     103    config['tg.default_renderer'] = 'genshi' 
     104         
     105    {{elif template_engine == 'jinja'}} 
     106    # Create the Jinja Environment 
     107    config['pylons.app_globals'].jinja_env = Environment(loader=ChoiceLoader( 
     108            [FileSystemLoader(path) for path in paths['templates']])) 
     109    # Jinja's unable to request c's attributes without strict_c 
     110    config['pylons.strict_c'] = True 
     111    config['tg.default_renderer'] = 'jinja' 
     112    {{endif}} 
     113     
     114    # config['template_engines'] contains a dictionary of renderers which you can update here 
     115    # the keys are the name of the rendering engine, and the values the rendering function.  
     116    # by default render_json, and render_genshi, and render_mako are available.  
     117     
     118    # app_globals['template_engines']['my_engine] = my_renderer 
     119     
    111120    # CONFIGURATION OPTIONS HERE (note: all config options will override 
    112121    # any Pylons config options)