forked from orbit-oss/flask
Merge branch 'master' into module-support
This commit is contained in:
commit
720bede150
2 changed files with 12 additions and 9 deletions
6
flask.py
6
flask.py
|
|
@ -94,14 +94,16 @@ class _RequestGlobals(object):
|
||||||
|
|
||||||
|
|
||||||
class Session(SecureCookie):
|
class Session(SecureCookie):
|
||||||
"""Expands the session for support for switching between permanent
|
"""Expands the session with support for switching between permanent
|
||||||
and non-permanent sessions.
|
and non-permanent sessions.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def _get_permanent(self):
|
def _get_permanent(self):
|
||||||
return self.get('_permanent', False)
|
return self.get('_permanent', False)
|
||||||
|
|
||||||
def _set_permanent(self, value):
|
def _set_permanent(self, value):
|
||||||
self['_permanent'] = bool(value)
|
self['_permanent'] = bool(value)
|
||||||
|
|
||||||
permanent = property(_get_permanent, _set_permanent)
|
permanent = property(_get_permanent, _set_permanent)
|
||||||
del _get_permanent, _set_permanent
|
del _get_permanent, _set_permanent
|
||||||
|
|
||||||
|
|
@ -581,7 +583,7 @@ class Flask(_PackageBoundObject):
|
||||||
#: :meth:`before_request` decorator.
|
#: :meth:`before_request` decorator.
|
||||||
self.after_request_funcs = {}
|
self.after_request_funcs = {}
|
||||||
|
|
||||||
#: a dictionary with list of functions that are called without arguments
|
#: a dictionary with list of functions that are called without argument
|
||||||
#: to populate the template context. They key of the dictionary is the
|
#: to populate the template context. They key of the dictionary is the
|
||||||
#: name of the module this function is active for, `None` for all
|
#: name of the module this function is active for, `None` for all
|
||||||
#: requests. Each returns a dictionary that the template context is
|
#: requests. Each returns a dictionary that the template context is
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,6 @@ import sys
|
||||||
import flask
|
import flask
|
||||||
import unittest
|
import unittest
|
||||||
import tempfile
|
import tempfile
|
||||||
import warnings
|
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from werkzeug import parse_date
|
from werkzeug import parse_date
|
||||||
|
|
||||||
|
|
@ -61,7 +60,7 @@ class BasicFunctionalityTestCase(unittest.TestCase):
|
||||||
assert sorted(rv.allow) == ['GET', 'HEAD']
|
assert sorted(rv.allow) == ['GET', 'HEAD']
|
||||||
rv = c.head('/')
|
rv = c.head('/')
|
||||||
assert rv.status_code == 200
|
assert rv.status_code == 200
|
||||||
assert not rv.data # head truncates
|
assert not rv.data # head truncates
|
||||||
assert c.post('/more').data == 'POST'
|
assert c.post('/more').data == 'POST'
|
||||||
assert c.get('/more').data == 'GET'
|
assert c.get('/more').data == 'GET'
|
||||||
rv = c.delete('/more')
|
rv = c.delete('/more')
|
||||||
|
|
@ -85,7 +84,7 @@ class BasicFunctionalityTestCase(unittest.TestCase):
|
||||||
assert sorted(rv.allow) == ['GET', 'HEAD']
|
assert sorted(rv.allow) == ['GET', 'HEAD']
|
||||||
rv = c.head('/')
|
rv = c.head('/')
|
||||||
assert rv.status_code == 200
|
assert rv.status_code == 200
|
||||||
assert not rv.data # head truncates
|
assert not rv.data # head truncates
|
||||||
assert c.post('/more').data == 'POST'
|
assert c.post('/more').data == 'POST'
|
||||||
assert c.get('/more').data == 'GET'
|
assert c.get('/more').data == 'GET'
|
||||||
rv = c.delete('/more')
|
rv = c.delete('/more')
|
||||||
|
|
@ -191,7 +190,7 @@ class BasicFunctionalityTestCase(unittest.TestCase):
|
||||||
flask.abort(404)
|
flask.abort(404)
|
||||||
@app.route('/error')
|
@app.route('/error')
|
||||||
def error():
|
def error():
|
||||||
1/0
|
1 // 0
|
||||||
c = app.test_client()
|
c = app.test_client()
|
||||||
rv = c.get('/')
|
rv = c.get('/')
|
||||||
assert rv.status_code == 404
|
assert rv.status_code == 404
|
||||||
|
|
@ -236,7 +235,8 @@ class BasicFunctionalityTestCase(unittest.TestCase):
|
||||||
def to_python(self, value):
|
def to_python(self, value):
|
||||||
return value.split(',')
|
return value.split(',')
|
||||||
def to_url(self, value):
|
def to_url(self, value):
|
||||||
return ','.join(super(ListConverter, self).to_url(x) for x in value)
|
base_to_url = super(ListConverter, self).to_url
|
||||||
|
return ','.join(base_to_url(x) for x in value)
|
||||||
app = flask.Flask(__name__)
|
app = flask.Flask(__name__)
|
||||||
app.url_map.converters['list'] = ListConverter
|
app.url_map.converters['list'] = ListConverter
|
||||||
@app.route('/<list:args>')
|
@app.route('/<list:args>')
|
||||||
|
|
@ -297,10 +297,11 @@ class JSONTestCase(unittest.TestCase):
|
||||||
|
|
||||||
def test_template_escaping(self):
|
def test_template_escaping(self):
|
||||||
app = flask.Flask(__name__)
|
app = flask.Flask(__name__)
|
||||||
|
render = flask.render_template_string
|
||||||
with app.test_request_context():
|
with app.test_request_context():
|
||||||
rv = flask.render_template_string('{{ "</script>"|tojson|safe }}')
|
rv = render('{{ "</script>"|tojson|safe }}')
|
||||||
assert rv == '"<\\/script>"'
|
assert rv == '"<\\/script>"'
|
||||||
rv = flask.render_template_string('{{ "<\0/script>"|tojson|safe }}')
|
rv = render('{{ "<\0/script>"|tojson|safe }}')
|
||||||
assert rv == '"<\\u0000\\/script>"'
|
assert rv == '"<\\u0000\\/script>"'
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue