Skip to content

Commit

Permalink
Fixed late binding of url_prefix. This fixes #29.
Browse files Browse the repository at this point in the history
  • Loading branch information
mitsuhiko committed May 4, 2010
1 parent 720bede commit a921aef
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion flask.py
Expand Up @@ -448,7 +448,7 @@ def add_url_rule(self, rule, endpoint, view_func=None, **options):
"""
def register_rule(state):
the_rule = rule
if self.url_prefix:
if state.url_prefix:
the_rule = state.url_prefix + rule
state.app.add_url_rule(the_rule, '%s.%s' % (self.name, endpoint),
view_func, **options)
Expand Down
9 changes: 9 additions & 0 deletions tests/flask_tests.py
Expand Up @@ -441,6 +441,15 @@ def index():
assert catched == ['before-app', 'before-admin',
'after-admin', 'after-app']

def test_late_binding(self):
app = flask.Flask(__name__)
admin = flask.Module(__name__, 'admin')
@admin.route('/')
def index():
return '42'
app.register_module(admin, url_prefix='/admin')
assert app.test_client().get('/admin/').data == '42'


def suite():
from minitwit_tests import MiniTwitTestCase
Expand Down

0 comments on commit a921aef

Please sign in to comment.