Show More
@@ -18,14 +18,14 b' def load_environment(global_conf, app_co' | |||||
18 | """ |
|
18 | """ | |
19 | # Pylons paths |
|
19 | # Pylons paths | |
20 | root = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) |
|
20 | root = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) | |
21 |
paths = dict(root |
|
21 | paths = dict(root=root, | |
22 |
controllers |
|
22 | controllers=os.path.join(root, 'controllers'), | |
23 |
static_files |
|
23 | static_files=os.path.join(root, 'public'), | |
24 |
templates |
|
24 | templates=[os.path.join(root, 'templates')]) | |
25 |
|
25 | |||
26 | # Initialize config with the basic options |
|
26 | # Initialize config with the basic options | |
27 |
config.init_app(global_conf, app_conf, package |
|
27 | config.init_app(global_conf, app_conf, package='pylons_app', | |
28 |
template_engine |
|
28 | template_engine='mako', paths=paths) | |
29 |
|
29 | |||
30 | config['routes.map'] = make_map() |
|
30 | config['routes.map'] = make_map() | |
31 | config['pylons.g'] = app_globals.Globals() |
|
31 | config['pylons.g'] = app_globals.Globals() | |
@@ -33,12 +33,12 b' def load_environment(global_conf, app_co' | |||||
33 |
|
33 | |||
34 | # Create the Mako TemplateLookup, with the default auto-escaping |
|
34 | # Create the Mako TemplateLookup, with the default auto-escaping | |
35 | config['pylons.g'].mako_lookup = TemplateLookup( |
|
35 | config['pylons.g'].mako_lookup = TemplateLookup( | |
36 |
directories |
|
36 | directories=paths['templates'], | |
37 |
error_handler |
|
37 | error_handler=handle_mako_error, | |
38 |
module_directory |
|
38 | module_directory=os.path.join(app_conf['cache_dir'], 'templates'), | |
39 |
|
|
39 | output_encoding='utf-8', | |
40 |
imports |
|
40 | imports=['from webhelpers.html import escape'], | |
41 |
default_filters |
|
41 | default_filters=['escape']) | |
42 |
|
42 | |||
43 | # CONFIGURATION OPTIONS HERE (note: all config options will override |
|
43 | # CONFIGURATION OPTIONS HERE (note: all config options will override | |
44 | # any Pylons config options) |
|
44 | # any Pylons config options) |
@@ -24,11 +24,18 b' class HgController(BaseController):' | |||||
24 | if request.environ['HTTP_ACCEPT'].find("mercurial") != -1 or \ |
|
24 | if request.environ['HTTP_ACCEPT'].find("mercurial") != -1 or \ | |
25 | request.environ['PATH_INFO'].find('raw-file') != -1: |
|
25 | request.environ['PATH_INFO'].find('raw-file') != -1: | |
26 | return response |
|
26 | return response | |
27 |
|
27 | try: | ||
28 | tmpl = ''.join(response) |
|
28 | tmpl = u''.join(response) | |
|
29 | template = Template(tmpl, lookup=request.environ['pylons.pylons']\ | |||
|
30 | .config['pylons.g'].mako_lookup) | |||
|
31 | ||||
|
32 | except (RuntimeError, UnicodeDecodeError): | |||
|
33 | log.info('disabling unicode due to encoding error') | |||
|
34 | response = g.hgapp(request.environ, self.start_response) | |||
|
35 | tmpl = ''.join(response) | |||
|
36 | template = Template(tmpl, lookup=request.environ['pylons.pylons']\ | |||
|
37 | .config['pylons.g'].mako_lookup, disable_unicode=True) | |||
29 |
|
38 | |||
30 | template = Template(tmpl, lookup=request.environ['pylons.pylons']\ |
|
|||
31 | .config['pylons.g'].mako_lookup) |
|
|||
32 |
|
39 | |||
33 | return template.render(g=g, c=c, session=session, h=h) |
|
40 | return template.render(g=g, c=c, session=session, h=h) | |
34 |
|
41 |
General Comments 0
You need to be logged in to leave comments.
Login now