merged with 0.5-maintenance
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by Armin Ronacher · committed by Armin Ronacher · parents 3f7ab17, 0a93c55 · Browse files · 3 files·+34 added−12 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
3 files+34 added−12 removed
- tests:+12 added−0 removed
- other:+22 added−12 removed
Provenance
- Commit
b004324- Tree
15883f6- Author
Armin Ronacher <armin.ronacher@active-4.com>- Committer
Armin Ronacher <armin.ronacher@active-4.com>- Parent 1
3f7ab17- Parent 2
0a93c55
3 files changed+34 added−12 removed
modified:flask/templating.py+12 added-10 removed
32 unmodified lines33 def __init__(self, app):34 self.app = app35 36 def get_source(self, environment, template):37- name = template38- loader = None37 try:38 module, name = template.split('/', 1)39 loader = self.app.modules[module].jinja_loader40+ if loader is None:41+ raise ValueError()42 except (ValueError, KeyError):43- pass44- if loader is None:43 loader = self.app.jinja_loader46- try:47- return loader.get_source(environment, name)48- except TemplateNotFound:49- # re-raise the exception with the correct fileame here.50- # (the one that includes the prefix)51- raise TemplateNotFound(template)44+ if loader is not None:45+ return loader.get_source(environment, template)46+ else:47+ try:48+ return loader.get_source(environment, name)49+ except TemplateNotFound:50+ pass51+ # raise the exception with the correct fileame here.52+ # (the one that includes the prefix)53+ raise TemplateNotFound(template)54 55 def list_templates(self):56 result = self.app.jinja_loader.list_templates()57 for name, module in self.app.modules.iteritems():31 unmodified linesmodified:tests/flask_tests.py+12 added
19 unmodified lines20 from contextlib import contextmanager21 from datetime import datetime22 from werkzeug import parse_date, parse_options_header23 from werkzeug.exceptions import NotFound24+from jinja2 import TemplateNotFound25 from cStringIO import StringIO26 27 example_path = os.path.join(os.path.dirname(__file__), '..', 'examples')28 sys.path.append(os.path.join(example_path, 'flaskr'))633 unmodified lines662 with app.test_request_context():663 assert flask.url_for('admin.static', filename='test.txt') \664 == '/admin/static/test.txt'665 666+ with app.test_request_context():667+ try:668+ flask.render_template('missing.html')669+ except TemplateNotFound, e:670+ assert e.name == 'missing.html'671+ else:672+ assert 0, 'expected exception'673+674+ with flask.Flask(__name__).test_request_context():675+ assert flask.render_template('nested/nested.txt') == 'I\'m nested'676+677 def test_safe_access(self):678 from moduleapp import app679 680 with app.test_request_context():280 unmodified linesmodified:CHANGES+10 added-2 removed
6 unmodified lines7 -----------8 9 Release date to be announced, codename to be decided.10 11+Version 0.5.112+-------------13+14+Bugfix Release, released on July 6th 201015+16+- fixes an issue with template loading from directories when modules17+ where used.18+19 Version 0.520 -----------21 14-Released on July 6th 2010, codename Calvados.22+Released on July 6th 2010, codename Calvados23 24 - fixed a bug with subdomains that was caused by the inability to25 specify the server name. The server name can now be set with26 the `SERVER_NAME` config key. This key is now also used to set33 unmodified lines60 61 Version 0.3.162 -------------63 56-Bugfix release, released May 28th 201064+Bugfix release, released on May 28th 201065 66 - fixed a error reporting bug with :meth:`flask.Config.from_envvar`67 - removed some unused code from flask68 - release does no longer include development leftover files (.git43 unmodified lines