From 4688cc3702e1ad93dcb579ae75d569223e2a357c Mon Sep 17 00:00:00 2001 From: Ethan Mosbaugh Date: Tue, 24 Jun 2014 10:11:34 -0700 Subject: [PATCH] allow sub-manager tasks to use own app rather than parent's --- flask_script/__init__.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/flask_script/__init__.py b/flask_script/__init__.py index 5a926ea..8a74138 100644 --- a/flask_script/__init__.py +++ b/flask_script/__init__.py @@ -143,18 +143,20 @@ def __call__(self, app=None, **kwargs): If your sub-Manager does not override this, any values for options will get lost. """ - if app is None: - app = self.app + if self.app is None: if app is None: raise Exception("There is no app here. This is unlikely to work.") + self.app = app + elif app is not None: + kwargs['app'] = app - if isinstance(app, Flask): + if isinstance(self.app, Flask): if kwargs: import warnings warnings.warn("Options will be ignored.") - return app + return self.app - app = app(**kwargs) + app = self.app(**kwargs) self.app = app return app