You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by ke...@apache.org on 2020/03/27 14:24:35 UTC
[allura] 01/01: [#8355] Py3 compatibility for memcached-backed
jinja bytecode
This is an automated email from the ASF dual-hosted git repository.
kentontaylor pushed a commit to branch kt/8355
in repository https://gitbox.apache.org/repos/asf/allura.git
commit 85dccfeed3953bc7511192c6e295b9dd9eb63df1
Author: Kenton Taylor <kt...@slashdotmedia.com>
AuthorDate: Fri Mar 27 14:24:17 2020 +0000
[#8355] Py3 compatibility for memcached-backed jinja bytecode
---
Allura/allura/config/app_cfg.py | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/Allura/allura/config/app_cfg.py b/Allura/allura/config/app_cfg.py
index 91f89cf..f795f2c 100644
--- a/Allura/allura/config/app_cfg.py
+++ b/Allura/allura/config/app_cfg.py
@@ -34,6 +34,8 @@ from __future__ import unicode_literals
from __future__ import absolute_import
import logging
from functools import partial
+import six
+import sys
import tg
from tg import app_globals as g
@@ -84,7 +86,10 @@ class AlluraJinjaRenderer(JinjaRenderer):
import pylibmc
from jinja2 import MemcachedBytecodeCache
client = pylibmc.Client([config['memcached_host']])
- bcc = MemcachedBytecodeCache(client, prefix='jinja2/{}/'.format(jinja2.__version__))
+ bcc_prefix = 'jinja2/{}/'.format(jinja2.__version__)
+ if six.PY3:
+ bcc_prefix += 'py{}{}/'.format(sys.version_info.major, sys.version_info.minor)
+ bcc = MemcachedBytecodeCache(client, prefix=bcc_prefix)
elif cache_type == 'filesystem':
from jinja2 import FileSystemBytecodeCache
bcc = FileSystemBytecodeCache(pattern='__jinja2_{}_%s.cache'.format(jinja2.__version__))