##// END OF EJS Templates
core: added ext_json as custom renderer using our ext_json lib for pyramid.
marcink -
r1664:0db868e6 default
parent child Browse files
Show More
@@ -0,0 +1,37 b''
1 # -*- coding: utf-8 -*-
2
3 # Copyright (C) 2010-2017 RhodeCode GmbH
4 #
5 # This program is free software: you can redistribute it and/or modify
6 # it under the terms of the GNU Affero General Public License, version 3
7 # (only), as published by the Free Software Foundation.
8 #
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
13 #
14 # You should have received a copy of the GNU Affero General Public License
15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
16 #
17 # This program is dual-licensed. If you wish to learn more about the
18 # RhodeCode Enterprise Edition, including its added features, Support services,
19 # and proprietary license terms, please see https://rhodecode.com/licenses/
20
21 from rhodecode.lib.ext_json import json
22
23
24 def pyramid_ext_json(info):
25 """
26 Custom json renderer for pyramid to use our ext_json lib
27 """
28 def _render(value, system):
29 request = system.get('request')
30 if request is not None:
31 response = request.response
32 ct = response.content_type
33 if ct == response.default_content_type:
34 response.content_type = 'application/json'
35 return json.dumps(value)
36
37 return _render
@@ -315,6 +315,10 b' def includeme(config):'
315 # Set the default renderer for HTML templates to mako.
315 # Set the default renderer for HTML templates to mako.
316 config.add_mako_renderer('.html')
316 config.add_mako_renderer('.html')
317
317
318 config.add_renderer(
319 name='json_ext',
320 factory='rhodecode.lib.ext_json_renderer.pyramid_ext_json')
321
318 # include RhodeCode plugins
322 # include RhodeCode plugins
319 includes = aslist(settings.get('rhodecode.includes', []))
323 includes = aslist(settings.get('rhodecode.includes', []))
320 for inc in includes:
324 for inc in includes:
General Comments 0
You need to be logged in to leave comments. Login now