References to undefined variables in templates were
silently ignored/converted to None/empty strings. This
makes coding lazy stuff easy, but it makes catching typos
harder.
(It would have catched one of the SQL things earlier!)
But on the other hand it might make the current templates
error out everywhere. In fact, early testing has shown two
instances, that errored out. Those are fixed with this
commit too.
If this turns out to make things more complex and useless
than actually solving any problems, it can easily be
dropped again.
{% trans date=media.created.strftime("%Y-%m-%d") -%}
Added on {{ date }}.
{%- endtrans %}
- {% if media['uploader'] == request.user._id or
- request.user['is_admin'] %}
+ {% if request.user and
+ (media.uploader == request.user._id or
+ request.user.is_admin) %}
{% set edit_url = request.urlgen('mediagoblin.edit.edit_media',
user= media.get_uploader.username,
media= media._id) %}
{% else %}
<div class="grid_6 alpha">
{% include "mediagoblin/utils/profile.html" %}
- {% if request.user._id == user._id or request.user.is_admin %}
+ {% if request.user and
+ (request.user._id == user._id or request.user.is_admin) %}
<a href="{{ request.urlgen('mediagoblin.edit.profile') }}?username={{
user.username }}">
{%- trans %}Edit profile{% endtrans -%}
if SETUP_JINJA_ENVS.has_key(locale):
return SETUP_JINJA_ENVS[locale]
+ # jinja2.StrictUndefined will give exceptions on references
+ # to undefined/unknown variables in templates.
template_env = jinja2.Environment(
loader=template_loader, autoescape=True,
+ undefined=jinja2.StrictUndefined,
extensions=['jinja2.ext.i18n', 'jinja2.ext.autoescape'])
template_env.install_gettext_callables(