diff --git a/rhodecode/lib/base.py b/rhodecode/lib/base.py --- a/rhodecode/lib/base.py +++ b/rhodecode/lib/base.py @@ -38,7 +38,7 @@ from pylons.controllers import WSGIContr from pylons.controllers.util import redirect from pylons.i18n import translation # marcink: don't remove this import -from pylons.templating import render_mako as render # noqa +from pylons.templating import render_mako, pylons_globals, literal, cached_template from pylons.i18n.translation import _ from webob.exc import HTTPFound @@ -65,6 +65,32 @@ from rhodecode.model.settings import Vcs log = logging.getLogger(__name__) +# hack to make the migration to pyramid easier +def render(template_name, extra_vars=None, cache_key=None, + cache_type=None, cache_expire=None): + """Render a template with Mako + + Accepts the cache options ``cache_key``, ``cache_type``, and + ``cache_expire``. + + """ + # Create a render callable for the cache function + def render_template(): + # Pull in extra vars if needed + globs = extra_vars or {} + + # Second, get the globals + globs.update(pylons_globals()) + + globs['_ungettext'] = globs['ungettext'] + # Grab a template reference + template = globs['app_globals'].mako_lookup.get_template(template_name) + + return literal(template.render_unicode(**globs)) + + return cached_template(template_name, render_template, cache_key=cache_key, + cache_type=cache_type, cache_expire=cache_expire) + def _filter_proxy(ip): """ Passed in IP addresses in HEADERS can be in a special format of multiple diff --git a/rhodecode/lib/partial_renderer.py b/rhodecode/lib/partial_renderer.py --- a/rhodecode/lib/partial_renderer.py +++ b/rhodecode/lib/partial_renderer.py @@ -64,7 +64,7 @@ class PyramidPartialRenderer(object): _kwargs = { '_': self.request.translate, - 'ungettext': self.request.plularize, + '_ungettext': self.request.plularize, 'h': self.get_helpers(), 'c': self.get_call_context(), diff --git a/rhodecode/lib/utils.py b/rhodecode/lib/utils.py --- a/rhodecode/lib/utils.py +++ b/rhodecode/lib/utils.py @@ -904,7 +904,7 @@ class PartialRenderer(object): 'h': self.h, 'c': self.c, 'request': self.request, - 'ungettext': self.ungettext, + '_ungettext': self.ungettext, } _kwargs.update(kwargs) return _kwargs diff --git a/rhodecode/templates/admin/repo_groups/repo_group_edit_advanced.mako b/rhodecode/templates/admin/repo_groups/repo_group_edit_advanced.mako --- a/rhodecode/templates/admin/repo_groups/repo_group_edit_advanced.mako +++ b/rhodecode/templates/admin/repo_groups/repo_group_edit_advanced.mako @@ -33,7 +33,7 @@
- ${ungettext('This user owns %s repository.', 'This user owns %s repositories.', len(c.user.repositories)) % len(c.user.repositories)} + ${_ungettext('This user owns %s repository.', 'This user owns %s repositories.', len(c.user.repositories)) % len(c.user.repositories)} | %if len(c.user.repositories) > 0: @@ -103,7 +103,7 @@ | |
- ${ungettext('This user owns %s repository group.', 'This user owns %s repository groups.', len(c.user.repository_groups)) % len(c.user.repository_groups)} + ${_ungettext('This user owns %s repository group.', 'This user owns %s repository groups.', len(c.user.repository_groups)) % len(c.user.repository_groups)} | %if len(c.user.repository_groups) > 0: @@ -119,7 +119,7 @@ | |
- ${ungettext('This user owns %s user group.', 'This user owns %s user groups.', len(c.user.user_groups)) % len(c.user.user_groups)} + ${_ungettext('This user owns %s user group.', 'This user owns %s user groups.', len(c.user.user_groups)) % len(c.user.user_groups)} | %if len(c.user.user_groups) > 0: diff --git a/rhodecode/templates/base/perms_summary.mako b/rhodecode/templates/base/perms_summary.mako --- a/rhodecode/templates/base/perms_summary.mako +++ b/rhodecode/templates/base/perms_summary.mako @@ -146,7 +146,7 @@ %if actions: |
%if section == 'repositories':
- ${_('edit')}
+ ${_('edit')}
%elif section == 'repositories_groups':
${_('edit')}
%elif section == 'user_groups':
diff --git a/rhodecode/templates/changeset/changeset.mako b/rhodecode/templates/changeset/changeset.mako
--- a/rhodecode/templates/changeset/changeset.mako
+++ b/rhodecode/templates/changeset/changeset.mako
@@ -163,14 +163,14 @@
%if c.comments:
- ${ungettext("%d Commit comment", "%d Commit comments", len(c.comments)) % len(c.comments)},
+ ${_ungettext("%d Commit comment", "%d Commit comments", len(c.comments)) % len(c.comments)},
%else:
- ${ungettext("%d Commit comment", "%d Commit comments", len(c.comments)) % len(c.comments)}
+ ${_ungettext("%d Commit comment", "%d Commit comments", len(c.comments)) % len(c.comments)}
%endif
%if c.inline_cnt:
- ${ungettext("%d Inline Comment", "%d Inline Comments", c.inline_cnt) % c.inline_cnt}
+ ${_ungettext("%d Inline Comment", "%d Inline Comments", c.inline_cnt) % c.inline_cnt}
%else:
- ${ungettext("%d Inline Comment", "%d Inline Comments", c.inline_cnt) % c.inline_cnt}
+ ${_ungettext("%d Inline Comment", "%d Inline Comments", c.inline_cnt) % c.inline_cnt}
%endif
|