fix(auto-merge): fixed _mako_lookup method.
This commit is contained in:
parent
9994abe2d9
commit
716f41c123
1 changed files with 16 additions and 2 deletions
|
|
@ -17,11 +17,17 @@
|
|||
# and proprietary license terms, please see https://rhodecode.com/licenses/
|
||||
|
||||
|
||||
import os
|
||||
import logging
|
||||
from pathlib import Path
|
||||
from pkg_resources import resource_filename
|
||||
|
||||
from mako import exceptions
|
||||
from pyramid.asset import resolve_asset_spec
|
||||
from pyramid.renderers import get_renderer
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
TEMPLATES_PATH = ""
|
||||
|
||||
|
||||
def get_partial_renderer(request, tmpl_name):
|
||||
|
|
@ -50,8 +56,16 @@ class PyramidPartialRenderer(object):
|
|||
except ValueError:
|
||||
# TODO: this is a workaround for exception happening with auto-merge enabled, to be replaced with proper fix
|
||||
from mako.lookup import TemplateLookup
|
||||
_tmpl_lookup = TemplateLookup(["rhodecode/templates", "rhodecode/templates/email_templates"])
|
||||
self.tmpl_name = self.tmpl_name.replace("rhodecode:templates/", "")
|
||||
|
||||
global TEMPLATES_PATH
|
||||
|
||||
if not TEMPLATES_PATH:
|
||||
package, filename = resolve_asset_spec(self.tmpl_name)
|
||||
template_path = os.path.dirname(resource_filename(package, filename))
|
||||
TEMPLATES_PATH = Path(template_path).as_posix()
|
||||
log.debug(f"Using {TEMPLATES_PATH} path")
|
||||
_tmpl_lookup = TemplateLookup([TEMPLATES_PATH])
|
||||
self.tmpl_name = Path(self.tmpl_name).name
|
||||
return _tmpl_lookup.get_template(self.tmpl_name)
|
||||
|
||||
def get_call_context(self):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue