Browse Source

merged with 0.5-maintenance

pull/112/head
Armin Ronacher 15 years ago
parent
commit
b004324dbb
  1. 12
      CHANGES
  2. 22
      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. 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 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 - fixed a bug with subdomains that was caused by the inability to
specify the server name. The server name can now be set with 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 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` - fixed a error reporting bug with :meth:`flask.Config.from_envvar`
- removed some unused code from flask - removed some unused code from flask

22
flask/templating.py

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

12
tests/flask_tests.py

@ -21,6 +21,7 @@ from contextlib import contextmanager
from datetime import datetime from datetime import datetime
from werkzeug import parse_date, parse_options_header from werkzeug import parse_date, parse_options_header
from werkzeug.exceptions import NotFound from werkzeug.exceptions import NotFound
from jinja2 import TemplateNotFound
from cStringIO import StringIO from cStringIO import StringIO
example_path = os.path.join(os.path.dirname(__file__), '..', 'examples') 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') \ assert flask.url_for('admin.static', filename='test.txt') \
== '/admin/static/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): def test_safe_access(self):
from moduleapp import app from moduleapp import app

Loading…
Cancel
Save