# HG changeset patch # User Marcin Kuzminski # Date 2018-11-18 09:04:19 # Node ID ea959a16edb0e0db6df30580463c6745f866f17e # Parent 95dfd17aca1f689eacb3dddad37444145ee00d56 utils: updated request generation so ishell can run some automation scripts. diff --git a/rhodecode/lib/pyramid_utils.py b/rhodecode/lib/pyramid_utils.py --- a/rhodecode/lib/pyramid_utils.py +++ b/rhodecode/lib/pyramid_utils.py @@ -37,6 +37,23 @@ def get_app_config(ini_path): return appconfig('config:{}'.format(ini_path), relative_to=os.getcwd()) +class BootstrappedRequest(Request): + """ + Special version of Request Which has some available methods like in pyramid. + Some code (used for template rendering) requires this, and we unsure it's present. + """ + + def translate(self, msg): + return msg + + def plularize(self, singular, plural, n): + return singular + + def get_partial_renderer(self, tmpl_name): + from rhodecode.lib.partial_renderer import get_partial_renderer + return get_partial_renderer(request=self, tmpl_name=tmpl_name) + + def bootstrap(config_uri, request=None, options=None, env=None): if env: os.environ.update(env) @@ -48,7 +65,7 @@ def bootstrap(config_uri, request=None, except (configparser.NoSectionError, configparser.NoOptionError): pass - request = request or Request.blank('/', base_url=base_url) + request = request or BootstrappedRequest.blank('/', base_url=base_url) return pyramid_bootstrap(config_uri, request=request, options=options)