Fixed a bug in list_templates
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 · parent 8d2daea · Browse files · 6 files·+23 added−5 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
6 files+23 added−5 removed
- tests:+12 added−4 removed
- other:+11 added−1 removed
Provenance
- Commit
c9a2ad2- Tree
c1c322a- Author
Armin Ronacher <armin.ronacher@active-4.com>- Committer
Armin Ronacher <armin.ronacher@active-4.com>- Parent
8d2daea
6 files changed+23 added−5 removed
modified:flask/templating.py+3 added-1 removed
76 unmodified lines77 except (ValueError, KeyError):78 pass79 80 for blueprint in self.app.blueprints.itervalues():81+ if blueprint_is_module(blueprint):82+ continue83 loader = blueprint.jinja_loader84 if loader is not None:85 yield loader, template86 7 unmodified lines94 loader = blueprint.jinja_loader95 if loader is not None:96 for template in loader.list_templates():97 prefix = ''96- if not blueprint_is_module(blueprint):98+ if blueprint_is_module(blueprint):99 prefix = name + '/'100 result.add(prefix + template)101 102 return list(result)36 unmodified linesmodified:tests/blueprintapp/apps/admin/__init__.py+3 added-1 removed
1 from flask import Blueprint, render_template2 3-admin = Blueprint(__name__, url_prefix='/admin')3+admin = Blueprint('admin', __name__, url_prefix='/admin',4+ template_folder='templates',5+ static_folder='static')6 7 8 @admin.route('/')9 def index():6 unmodified linesmodified:tests/blueprintapp/apps/frontend/__init__.py+1 added-1 removed
1 from flask import Blueprint, render_template2 3-frontend = Blueprint(__name__)3+frontend = Blueprint('frontend', __name__, template_folder='templates')4 5 6 @frontend.route('/')7 def index():1 unmodified linemodified:tests/blueprintapp/__init__.py+2 added-2 removed
1 from flask import Flask2 3 app = Flask(__name__)4-from moduleapp.apps.admin import admin5-from moduleapp.apps.frontend import frontend4+from blueprintapp.apps.admin import admin5+from blueprintapp.apps.frontend import frontend6 app.register_blueprint(admin)7 app.register_blueprint(frontend)modified:tests/flask_tests.py+6 added
1412 unmodified lines1413 1414 with flask.Flask(__name__).test_request_context():1415 assert flask.render_template('nested/nested.txt') == 'I\'m nested'1416 1417+ def test_templates_list(self):1418+ from blueprintapp import app1419+ templates = sorted(app.jinja_env.list_templates())1420+ self.assertEqual(templates, ['admin/index.html',1421+ 'frontend/index.html'])1422+1423 def test_dotted_names(self):1424 frontend = flask.Blueprint('myapp.frontend', __name__)1425 backend = flask.Blueprint('myapp.backend', __name__)1426 547 unmodified linesmodified:CHANGES+8 added
13 unmodified lines14 - Empty session cookies are now deleted properly automatically.15 - View functions can now opt out of getting the automatic16 OPTIONS implementation.17 18+Version 0.7.319+-------------20+21+Bugfix release, release date to be decided22+23+- Fixed the Jinja2 environment's list_templates method not returning the24+ correct names when blueprints or modules were involved.25+26 Version 0.7.227 -------------28 29 Bugfix release, released on July 6th 2011229 unmodified lines