+
This is blueprint example
+
+ A simple page blueprint is registered under / and /pages
+ you can access it using this urls:
+
+
+
+ Also you can register the same blueprint under another path
+
+
+
+
+
+ {% block body %}
+ {% endblock %}
+
\ No newline at end of file
diff --git a/examples/blueprintexample/simple_page/templates/pages/world.html b/examples/blueprintexample/simple_page/templates/pages/world.html
new file mode 100644
index 00000000..bdb5b16b
--- /dev/null
+++ b/examples/blueprintexample/simple_page/templates/pages/world.html
@@ -0,0 +1,5 @@
+{% extends "pages/layout.html" %}
+
+{% block body %}
+ World
+{% endblock %}
\ No newline at end of file
diff --git a/flask/app.py b/flask/app.py
index 9254c398..d30d3809 100644
--- a/flask/app.py
+++ b/flask/app.py
@@ -1490,7 +1490,7 @@ class Flask(_PackageBoundObject):
"""
funcs = self.url_default_functions.get(None, ())
if '.' in endpoint:
- bp = endpoint.split('.', 1)[0]
+ bp = endpoint.rsplit('.', 1)[0]
funcs = chain(funcs, self.url_default_functions.get(bp, ()))
for func in funcs:
func(endpoint, values)
diff --git a/flask/ctx.py b/flask/ctx.py
index 90858aa4..0cf34491 100644
--- a/flask/ctx.py
+++ b/flask/ctx.py
@@ -40,7 +40,7 @@ def after_this_request(f):
@app.route('/')
def index():
@after_this_request
- def add_header():
+ def add_header(response):
response.headers['X-Foo'] = 'Parachute'
return response
return 'Hello World!'
diff --git a/flask/helpers.py b/flask/helpers.py
index f714a699..631e29be 100644
--- a/flask/helpers.py
+++ b/flask/helpers.py
@@ -118,31 +118,9 @@ def jsonify(*args, **kwargs):
information about this, have a look at :ref:`json-security`.
.. versionadded:: 0.2
-
- .. versionadded:: 0.9
- If the ``padded`` argument is true, the JSON object will be padded
- for JSONP calls and the response mimetype will be changed to
- ``application/javascript``. By default, the request arguments ``callback``
- and ``jsonp`` will be used as the name for the callback function.
- This will work with jQuery and most other JavaScript libraries
- by default.
-
- If the ``padded`` argument is a string, jsonify will look for
- the request argument with the same name and use that value as the
- callback-function name.
"""
if __debug__:
_assert_have_json()
- if 'padded' in kwargs:
- if isinstance(kwargs['padded'], str):
- callback = request.args.get(kwargs['padded']) or 'jsonp'
- else:
- callback = request.args.get('callback') or \
- request.args.get('jsonp') or 'jsonp'
- del kwargs['padded']
- json_str = json.dumps(dict(*args, **kwargs), indent=None)
- content = str(callback) + "(" + json_str + ")"
- return current_app.response_class(content, mimetype='application/javascript')
return current_app.response_class(json.dumps(dict(*args, **kwargs),
indent=None if request.is_xhr else 2), mimetype='application/json')
@@ -529,7 +507,7 @@ def send_file(filename_or_fp, mimetype=None, as_attachment=False,
rv.cache_control.public = True
if cache_timeout is None:
cache_timeout = current_app.get_send_file_max_age(filename)
- if cache_timeout:
+ if cache_timeout is not None:
rv.cache_control.max_age = cache_timeout
rv.expires = int(time() + cache_timeout)
diff --git a/flask/testsuite/basic.py b/flask/testsuite/basic.py
index ba6c2705..388b5a8e 100644
--- a/flask/testsuite/basic.py
+++ b/flask/testsuite/basic.py
@@ -953,6 +953,29 @@ class BasicFunctionalityTestCase(FlaskTestCase):
self.assert_equal(c.get('/de/').data, '/de/about')
self.assert_equal(c.get('/de/about').data, '/foo')
self.assert_equal(c.get('/foo').data, '/en/about')
+
+ def test_inject_blueprint_url_defaults(self):
+ app = flask.Flask(__name__)
+ bp = flask.Blueprint('foo.bar.baz', __name__,
+ template_folder='template')
+
+ @bp.url_defaults
+ def bp_defaults(endpoint, values):
+ values['page'] = 'login'
+ @bp.route('/