8000 trying to fix registering multiple models · jstacoder/flask-xxl@d3d5ce4 · GitHub
[go: up one dir, main page]

S 8000 kip to content

Commit d3d5ce4

Browse files
committed
trying to fix registering multiple models
1 parent f51a1de commit d3d5ce4

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

flask_xxl/main.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,15 @@ def _register_routes(self):
181181
if self.app.config.get('VERBOSE',False):
182182
print 'Finished registering blueprints and url routes'
183183
else:
184-
print 'skip[ped'
184+
if self.app.config.get('VERBOSE',False):
185+
print 'skipped'
186+
187+
def _check_for_registered_blueprint(self, bp):
188+
found = False
189+
for name in [str(x) for x in self.app.blueprints]:
190+
if bp.__name__.split('.')[-1] in name:
191+
found = True
192+
return found
185193

186194
def _setup_routes(self,routes):
187195
for route in routes:
@@ -202,7 +210,7 @@ def _setup_routes(self,routes):
202210
if type(blueprint) == type(tuple()):
203211
blueprint = blueprint[0]
204212
blueprint.add_url_rule(pattern,endpoint or view.func_name,view_func=hasattr(view,'func_name') and view or view.as_view(endpoint))
205-
if not blueprint in self.app.blueprints:
213+
if not self._check_for_registered_blueprint(blueprint):
206214
if self.app.config.get('VERBOSE',False):
207215
print '\n\t\t\tNow registering {} as blueprint\n\n'.format(str(blueprint.name))
208216
self.app.register_blueprint(blueprint)

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
VERSION = '0,9,16'
1+
VERSION = '0,9,17'
22
import os
33
from setuptools import setup, find_packages,findall
44
from glob import glob

0 commit comments

Comments
 (0)
0