Browse Source

merged with 0.5-maintenance

pull/112/head
Armin Ronacher 15 years ago
parent
commit
b004324dbb
  1. 12
      CHANGES
  2. 12
      flask/templating.py
  3. 12
      tests/flask_tests.py

12
CHANGES

@ -8,10 +8,18 @@ Version 0.6
Release date to be announced, codename to be decided.
Version 0.5.1
-------------
Bugfix Release, released on July 6th 2010
- fixes an issue with template loading from directories when modules
where used.
Version 0.5
-----------
Released on July 6th 2010, codename Calvados.
Released on July 6th 2010, codename Calvados
- fixed a bug with subdomains that was caused by the inability to
specify the server name. The server name can now be set with
@ -53,7 +61,7 @@ Released on June 18th 2010, codename Rakia
Version 0.3.1
-------------
Bugfix release, released May 28th 2010
Bugfix release, released on May 28th 2010
- fixed a error reporting bug with :meth:`flask.Config.from_envvar`
- removed some unused code from flask

12
flask/templating.py

@ -34,19 +34,21 @@ class _DispatchingJinjaLoader(BaseLoader):
self.app = app
def get_source(self, environment, template):
name = template
loader = None
try:
module, name = template.split('/', 1)
loader = self.app.modules[module].jinja_loader
except (ValueError, KeyError):
pass
if loader is None:
raise ValueError()
except (ValueError, KeyError):
loader = self.app.jinja_loader
if loader is not None:
return loader.get_source(environment, template)
else:
try:
return loader.get_source(environment, name)
except TemplateNotFound:
# re-raise the exception with the correct fileame here.
pass
# raise the exception with the correct fileame here.
# (the one that includes the prefix)
raise TemplateNotFound(template)

12
tests/flask_tests.py

@ -21,6 +21,7 @@ from contextlib import contextmanager
from datetime import datetime
from werkzeug import parse_date, parse_options_header
from werkzeug.exceptions import NotFound
from jinja2 import TemplateNotFound
from cStringIO import StringIO
example_path = os.path.join(os.path.dirname(__file__), '..', 'examples')
@ -662,6 +663,17 @@ class ModuleTestCase(unittest.TestCase):
assert flask.url_for('admin.static', filename='test.txt') \
== '/admin/static/test.txt'
with app.test_request_context():
try:
flask.render_template('missing.html')
except TemplateNotFound, e:
assert e.name == 'missing.html'
else:
assert 0, 'expected exception'
with flask.Flask(__name__).test_request_context():
assert flask.render_template('nested/nested.txt') == 'I\'m nested'
def test_safe_access(self):
from moduleapp import app

Loading…
Cancel
Save