Skip to content

Commit ade5c08

Browse files
committed
Merge branch 'master' into new-modules
2 parents 18bfb4f + 6e3dd9b commit ade5c08

File tree

10 files changed

+39
-9
lines changed

10 files changed

+39
-9
lines changed

CHANGES

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ Bugfix release, release date to be announced.
3333
- Jinja2 template loading syntax now allows "./" in front of
3434
a template load path. Previously this caused issues with
3535
module setups.
36+
- Fixed an issue where the subdomain setting for modules was
37+
ignored for the static folder.
3638

3739
Version 0.6
3840
-----------

docs/patterns/fabric.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ virtual environment::
5050
# figure out the release name and version
5151
dist = local('python setup.py --fullname').strip()
5252
# upload the source tarball to the temporary folder on the server
53-
put('sdist/%s.tar.gz' % dist, '/tmp/yourapplication.tar.gz')
53+
put('dist/%s.tar.gz' % dist, '/tmp/yourapplication.tar.gz')
5454
# create a place where we can unzip the tarball, then enter
5555
# that directory and unzip it
5656
run('mkdir yourapplication')

docs/patterns/flashing.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ template that does this.
1414
Simple Flashing
1515
---------------
1616

17-
So here a full example::
17+
So here is a full example::
1818

1919
from flask import flash, redirect, url_for, render_template
2020

docs/patterns/viewdecorators.rst

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,9 @@ As you can see, if no template name is provided it will use the endpoint
120120
of the URL map with dots converted to slashes + ``'.html'``. Otherwise
121121
the provided template name is used. When the decorated function returns,
122122
the dictionary returned is passed to the template rendering function. If
123-
`None` is returned, an empty dictionary is assumed.
123+
`None` is returned, an empty dictionary is assumed, if something else than
124+
a dictionary is returned we return it from the function unchanged. That
125+
way you can still use the redirect function or return simple strings.
124126

125127
Here the code for that decorator::
126128

@@ -138,6 +140,8 @@ Here the code for that decorator::
138140
ctx = f(*args, **kwargs)
139141
if ctx is None:
140142
ctx = {}
143+
elif not isinstance(ctx, dict):
144+
return ctx
141145
return render_template(template_name, **ctx)
142146
return decorated_function
143147
return decorator

docs/signals.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ to the template::
5555
@contextmanager
5656
def captured_templates(app):
5757
recorded = []
58-
def record(template, context):
58+
def record(sender, template, context):
5959
recorded.append((template, context))
6060
template_rendered.connect(record, app)
6161
try:
@@ -87,7 +87,7 @@ its own which simplifies the example above::
8787

8888
def captured_templates(app):
8989
recorded = []
90-
def record(template, context):
90+
def record(sender, template, context):
9191
recorded.append((template, context))
9292
return template_rendered.connected_to(record, app)
9393

@@ -155,7 +155,7 @@ With Blinker 1.1 you can also easily subscribe to signals by using the new
155155
from flask import template_rendered
156156

157157
@template_rendered.connect_via(app)
158-
def when_template_rendered(template, context):
158+
def when_template_rendered(sender, template, context):
159159
print 'Template %s is rendered with %s' % (template.name, context)
160160

161161
Core Signals

docs/testing.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ In order to test that, we add a second module (
4343
class FlaskrTestCase(unittest.TestCase):
4444

4545
def setUp(self):
46-
self.db_fd, self.app.config['DATABASE'] = tempfile.mkstemp()
46+
self.db_fd, flaskr.app.config['DATABASE'] = tempfile.mkstemp()
4747
self.app = flaskr.app.test_client()
4848
flaskr.init_db()
4949

flask/module.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ def _register(state):
4242
path = state.url_prefix + path
4343
state.app.add_url_rule(path + '/<path:filename>',
4444
endpoint='%s.static' % module.name,
45-
view_func=module.send_static_file)
45+
view_func=module.send_static_file,
46+
subdomain=module.subdomain)
4647
return _register
4748

4849

tests/flask_tests.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,13 @@ def index():
248248
flask.session['test'] = 42
249249
flask.session.permanent = permanent
250250
return ''
251-
rv = app.test_client().get('/')
251+
252+
@app.route('/test')
253+
def test():
254+
return unicode(flask.session.permanent)
255+
256+
client = app.test_client()
257+
rv = client.get('/')
252258
assert 'set-cookie' in rv.headers
253259
match = re.search(r'\bexpires=([^;]+)', rv.headers['set-cookie'])
254260
expires = parse_date(match.group())
@@ -257,6 +263,9 @@ def index():
257263
assert expires.month == expected.month
258264
assert expires.day == expected.day
259265

266+
rv = client.get('/test')
267+
assert rv.data == 'True'
268+
260269
permanent = False
261270
rv = app.test_client().get('/')
262271
assert 'set-cookie' in rv.headers
@@ -1102,6 +1111,15 @@ def test_index():
11021111
rv = c.get('/', 'http://test.localhost/')
11031112
assert rv.data == 'test index'
11041113

1114+
def test_module_static_path_subdomain(self):
1115+
app = flask.Flask(__name__)
1116+
app.config['SERVER_NAME'] = 'example.com'
1117+
from subdomaintestmodule import mod
1118+
app.register_module(mod)
1119+
c = app.test_client()
1120+
rv = c.get('/static/hello.txt', 'http://foo.example.com/')
1121+
assert rv.data.strip() == 'Hello Subdomain'
1122+
11051123
def test_subdomain_matching(self):
11061124
app = flask.Flask(__name__)
11071125
app.config['SERVER_NAME'] = 'localhost'

tests/subdomaintestmodule/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
from flask import Module
2+
3+
4+
mod = Module(__name__, 'foo', subdomain='foo')
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Hello Subdomain

0 commit comments

Comments
 (0)