Skip to content

Commit

Permalink
use the existing Jinja2 environment
Browse files Browse the repository at this point in the history
  • Loading branch information
ewdurbin committed Feb 23, 2021
1 parent 0f27009 commit 3745775
Showing 1 changed file with 2 additions and 10 deletions.
12 changes: 2 additions & 10 deletions warehouse/packaging/utils.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import hashlib
import os.path

from jinja2 import Environment, FileSystemLoader
from pyramid_jinja2 import IJinja2Environment

import warehouse

Expand All @@ -11,15 +11,7 @@
def render_simple_detail(project, request, store=False):
context = _simple_detail(project, request)

# TODO: use pyramid_jinja2 "get_jinja2_environment" method instead:
# https://docs.pylonsproject.org/projects/pyramid_jinja2/en/latest/api.html#pyramid_jinja2.get_jinja2_environment
dir_name = os.path.join(os.path.dirname(warehouse.__file__), "templates")
env = Environment(
loader=FileSystemLoader(dir_name),
extensions=[],
cache_size=0,
)

env = request.registry.queryUtility(IJinja2Environment, name=".jinja2")
template = env.get_template("legacy/api/simple/detail.html")
content = template.render(**context, request=request)

Expand Down

0 comments on commit 3745775

Please sign in to comment.