From commits-return-17215-apmail-allura-commits-archive=allura.apache.org@allura.apache.org Fri Mar 27 14:24:35 2020 Return-Path: X-Original-To: apmail-allura-commits-archive@www.apache.org Delivered-To: apmail-allura-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [207.244.88.153]) by minotaur.apache.org (Postfix) with SMTP id 3045D19C1F for ; Fri, 27 Mar 2020 14:24:35 +0000 (UTC) Received: (qmail 29880 invoked by uid 500); 27 Mar 2020 14:24:34 -0000 Delivered-To: apmail-allura-commits-archive@allura.apache.org Received: (qmail 29848 invoked by uid 500); 27 Mar 2020 14:24:34 -0000 Mailing-List: contact commits-help@allura.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@allura.apache.org Delivered-To: mailing list commits@allura.apache.org Received: (qmail 29823 invoked by uid 99); 27 Mar 2020 14:24:34 -0000 Received: from ec2-52-202-80-70.compute-1.amazonaws.com (HELO gitbox.apache.org) (52.202.80.70) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 27 Mar 2020 14:24:34 +0000 Received: by gitbox.apache.org (ASF Mail Server at gitbox.apache.org, from userid 33) id 590D381A09; Fri, 27 Mar 2020 14:24:34 +0000 (UTC) Date: Fri, 27 Mar 2020 14:24:35 +0000 To: "commits@allura.apache.org" Subject: [allura] 01/01: [#8355] Py3 compatibility for memcached-backed jinja bytecode MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit From: kentontaylor@apache.org In-Reply-To: <158531907424.27375.12255449513721440603@gitbox.apache.org> References: <158531907424.27375.12255449513721440603@gitbox.apache.org> X-Git-Host: gitbox.apache.org X-Git-Repo: allura X-Git-Refname: refs/heads/kt/8355 X-Git-Reftype: branch X-Git-Rev: 85dccfeed3953bc7511192c6e295b9dd9eb63df1 X-Git-NotificationType: diff X-Git-Multimail-Version: 1.5.dev Auto-Submitted: auto-generated Message-Id: <20200327142434.590D381A09@gitbox.apache.org> 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 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__))