Skip to content

Commit

Permalink
🐛 Fix repeated loading of jinja tempaltes
Browse files Browse the repository at this point in the history
  • Loading branch information
dankolbman committed Jun 7, 2018
1 parent 99d5b7f commit 6bc73a9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions dataservice/api/common/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ class CRUDView(MethodView):
schemas = {}
endpoint = None
rule = '/'
temp_env = jinja2.Environment(
loader=jinja2.PackageLoader('dataservice.api', 'templates')
)

def __init__(self, *args, **kwargs):
super(CRUDView, self).__init__(*args, **kwargs)
Expand Down Expand Up @@ -159,10 +162,7 @@ def _render_template(template_name, **props):
"""
Renders a yaml file templated with jinja2 and deserializes to a dict
"""
env = jinja2.Environment(
loader=jinja2.PackageLoader('dataservice.api', 'templates')
)
template = env.get_template(template_name)
template = CRUDView.temp_env.get_template(template_name)
return yaml.safe_load(template.render(**props))

@classmethod
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ Flask-Migrate==2.1.1
Flask-Profile==0.2
Flask-SQLAlchemy==2.3.2
itsdangerous==0.24
Jinja2==2.8
Mako==1.0.4
MarkupSafe==0.23
python-editor==1.0.3
Expand All @@ -24,3 +23,4 @@ psycopg2==2.7.3.2
webargs==3.0.0
boto3==1.7.8
botocore==1.10.8
Jinja2==2.10

0 comments on commit 6bc73a9

Please sign in to comment.