Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Incomplete traceback when extending templates twice #144

Open
equake opened this Issue · 0 comments

1 participant

@equake

Hi!

My templates have the following hypothetical structure:

poc.html:

{% extends "product/poc-base-turbo.html" %}
{% block content_turbo %}
    {{ a }}
    {{ b }}
    {{ c }}
    {{ a.b.c }}
{% endblock %}

poc-base-turbo.html:

{% extends "product/poc-base.html" %}
{% block content %}
    x
    {% block content_turbo %}
    {% endblock %}
    y
{% endblock %}

poc-base.html:

header
{% block content %}
{% endblock %}
footer

Imagine that "a.b.c" is undefined. When rendering the template, I receive the following incomplete traceback:

2012-08-10 18:27:33,327  DEBUG  magazineluiza.site.system.error:34 - Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/bottle.py", line 737, in _handle
    return route.call(**args)
  File "/usr/local/lib/python2.7/dist-packages/bottle.py", line 1456, in wrapper
    rv = callback(*a, **ka)
  File "/home/marcos/Documents/workspace/ml-site-python/src/main/python/magazineluiza/site/system/context.py", line 231, in wrapper
    return render_html(view_name, rv, context_request)
  File "/home/marcos/Documents/workspace/ml-site-python/src/main/python/magazineluiza/site/system/context.py", line 283, in render_html
    return __fetch_template(context_request.theme, view_name, **params)
  File "/home/marcos/Documents/workspace/ml-site-python/src/main/python/magazineluiza/site/system/context.py", line 258, in __fetch_template
    return env.get_template(view_name).render(**params)
  File "/usr/local/lib/python2.7/dist-packages/Jinja2-2.6-py2.7.egg/jinja2/environment.py", line 894, in render
    return self.environment.handle_exception(exc_info, True)
  File "/home/marcos/Documents/workspace/ml-site-python/src/main/python/magazineluiza/site/view/desktop/product/poc.html", line 1, in top-level template code
    {% extends "product/poc-base-turbo.html" %}
  File "/home/marcos/Documents/workspace/ml-site-python/src/main/python/magazineluiza/site/view/desktop/product/poc-base-turbo.html", line 1, in top-level template code
    {% extends "product/poc-base.html" %}
  File "/home/marcos/Documents/workspace/ml-site-python/src/main/python/magazineluiza/site/view/desktop/product/poc-base.html", line 3, in top-level template code
    {% block content %}
  File "/home/marcos/Documents/workspace/ml-site-python/src/main/python/magazineluiza/site/view/desktop/product/poc-base-turbo.html", line 5, in block "content"
    {% block content_turbo %}
UndefinedError: 'str object' has no attribute 'b'

If I change my structure to:
poc.html:

{% extends "product/poc-base.html" %}
{% block content_turbo %}
    {{ a }}
    {{ b }}
    {{ c }}
    {{ a.b.c }}
{% endblock %}

poc-base.html:

header
{% block content %}
    x
    {% block content_turbo %}
    {% endblock %}
    y
{% endblock %}
footer

Everything works as it should! The traceback points to the right template/line now.

2012-08-10 18:42:32,594  DEBUG  magazineluiza.site.system.error:34 - Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/bottle.py", line 737, in _handle
    return route.call(**args)
  File "/usr/local/lib/python2.7/dist-packages/bottle.py", line 1456, in wrapper
    rv = callback(*a, **ka)
  File "/home/marcos/Documents/workspace/ml-site-python/src/main/python/magazineluiza/site/system/context.py", line 231, in wrapper
    return render_html(view_name, rv, context_request)
  File "/home/marcos/Documents/workspace/ml-site-python/src/main/python/magazineluiza/site/system/context.py", line 283, in render_html
    return __fetch_template(context_request.theme, view_name, **params)
  File "/home/marcos/Documents/workspace/ml-site-python/src/main/python/magazineluiza/site/system/context.py", line 258, in __fetch_template
    return env.get_template(view_name).render(**params)
  File "/usr/local/lib/python2.7/dist-packages/Jinja2-2.6-py2.7.egg/jinja2/environment.py", line 894, in render
    return self.environment.handle_exception(exc_info, True)
  File "/home/marcos/Documents/workspace/ml-site-python/src/main/python/magazineluiza/site/view/desktop/product/poc.html", line 1, in top-level template code
    {% extends "product/poc-base.html" %}
  File "/home/marcos/Documents/workspace/ml-site-python/src/main/python/magazineluiza/site/view/desktop/product/poc-base.html", line 2, in top-level template code
    {% block content %}
  File "/home/marcos/Documents/workspace/ml-site-python/src/main/python/magazineluiza/site/view/desktop/product/poc-base.html", line 4, in block "content"
    {% block content_turbo %}
  File "/home/marcos/Documents/workspace/ml-site-python/src/main/python/magazineluiza/site/view/desktop/product/poc.html", line 7, in block "content_turbo"
    {{ a.b.c }}
UndefinedError: 'str object' has no attribute 'b'

Am I doing anything wrong? Is this a bug?

Thanks!!
Marcos

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.