Fixing the model shortcut in pecan shell.
This commit is contained in:
@@ -31,8 +31,7 @@ class ShellCommand(Command):
|
|||||||
locs['wsgiapp'] = app
|
locs['wsgiapp'] = app
|
||||||
locs['app'] = TestApp(app)
|
locs['app'] = TestApp(app)
|
||||||
|
|
||||||
# find the model for the app
|
model = self.load_model(app.config)
|
||||||
model = getattr(app, 'model', None)
|
|
||||||
if model:
|
if model:
|
||||||
locs['model'] = model
|
locs['model'] = model
|
||||||
|
|
||||||
@@ -65,3 +64,10 @@ class ShellCommand(Command):
|
|||||||
except ImportError:
|
except ImportError:
|
||||||
pass
|
pass
|
||||||
shell.interact(shell_banner + banner)
|
shell.interact(shell_banner + banner)
|
||||||
|
|
||||||
|
def load_model(self, config):
|
||||||
|
for package_name in getattr(config.app, 'modules', []):
|
||||||
|
module = __import__(package_name, fromlist=['model'])
|
||||||
|
if hasattr(module, 'model'):
|
||||||
|
return module.model
|
||||||
|
return None
|
||||||
|
|||||||
Reference in New Issue
Block a user