Skip to content

Commit c76e4e7

Browse files
committed
use the existing Jinja2 environment
1 parent f0f8c20 commit c76e4e7

File tree

1 file changed

+2
-10
lines changed

1 file changed

+2
-10
lines changed

warehouse/packaging/utils.py

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import hashlib
22
import os.path
33

4-
from jinja2 import Environment, FileSystemLoader
4+
from pyramid_jinja2 import IJinja2Environment
55

66
import warehouse
77

@@ -11,15 +11,7 @@
1111
def render_simple_detail(project, request, store=False):
1212
context = _simple_detail(project, request)
1313

14-
# TODO: use pyramid_jinja2 "get_jinja2_environment" method instead:
15-
# https://docs.pylonsproject.org/projects/pyramid_jinja2/en/latest/api.html#pyramid_jinja2.get_jinja2_environment
16-
dir_name = os.path.join(os.path.dirname(warehouse.__file__), "templates")
17-
env = Environment(
18-
loader=FileSystemLoader(dir_name),
19-
extensions=[],
20-
cache_size=0,
21-
)
22-
14+
env = request.registry.queryUtility(IJinja2Environment, name=".jinja2")
2315
template = env.get_template("legacy/api/simple/detail.html")
2416
content = template.render(**context, request=request)
2517

0 commit comments

Comments
 (0)