Skip to content

Commit

Permalink
Merge branch 'hotfix/2014.05.19.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
krak3n committed Jul 7, 2014
2 parents 1c6035e + 2fdb90c commit 86dedc3
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 14 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
Change Log
==========

2014.05.19.1
------------
* Hotfix: Fixed issue where routes would be reregistered with an app
incorrectly in the event of multiple app creations

2014.05.19
----------
* Feature: ``Include`` now supports ``endpoint`` prefixing
Expand Down
2 changes: 1 addition & 1 deletion REQS.TESTING.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@

pytest==2.5.2
pytest-cov==1.6
pytest_spec==0.2.17
pytest_spec==0.2.22

Flask-Testing
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2014.05.19
2014.05.19.1
2 changes: 2 additions & 0 deletions flask_via/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,5 +143,7 @@ def init_app(
# Get the routes
routes = self.include(routes_module, routes_name)

print routes

# Load the routes
self.load(app, routes, **kwargs)
2 changes: 1 addition & 1 deletion flask_via/examples/include/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@
via.init_app(app)

if __name__ == '__main__':
app.run(debug=True)
app.run(debug=False)
36 changes: 25 additions & 11 deletions flask_via/routers/default.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,19 +88,26 @@ def add_to_app(self, app, **kwargs):
Arbitrary keyword arguments passed in to ``init_app``
"""

url = self.url
endpoint = self.endpoint

#: If this route was included a url preifx may have been passed
#: to the route
if 'url_prefix' in kwargs:
self.url = kwargs['url_prefix'] + self.url
url = kwargs['url_prefix'] + url

#: If this route was included a endpoint prefix may have been passed
#: to the route
if 'endpoint' in kwargs:
if self.endpoint is None:
self.endpoint = self.func.__name__
self.endpoint = kwargs['endpoint'] + self.endpoint
if endpoint is None:
endpoint = self.func.__name__
endpoint = kwargs['endpoint'] + endpoint

app.add_url_rule(self.url, self.endpoint, self.func)
try:
app.add_url_rule(url, endpoint, self.func)
except AssertionError:
# TODO: Log / Warn
pass


class Basic(Functional):
Expand Down Expand Up @@ -183,20 +190,27 @@ def add_to_app(self, app, **kwargs):
Arbitrary keyword arguments passed in to ``init_app``
"""

url = self.url
endpoint = self.endpoint

#: If this route was included a url preifx may have been passed
#: to the route
if 'url_prefix' in kwargs:
self.url = kwargs['url_prefix'] + self.url
url = kwargs['url_prefix'] + url

#: If this route was included a endpoint prefix may have been passed
#: to the route
if 'endpoint' in kwargs:
self.endpoint = kwargs['endpoint'] + self.endpoint
endpoint = kwargs['endpoint'] + endpoint

app.add_url_rule(
self.url,
view_func=self.view.as_view(self.endpoint),
**self.kwargs)
try:
app.add_url_rule(
url,
view_func=self.view.as_view(endpoint),
**self.kwargs)
except AssertionError:
# TODO: Log / Warn
pass


class Blueprint(BaseRouter, RoutesImporter):
Expand Down

0 comments on commit 86dedc3

Please sign in to comment.