Advertisement
chaosagent

flask db compiler

Feb 10th, 2016
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. # Initialize models and compile SQLAlchemy object list
  2. app_models_file_path = self_path / pathlib.Path('%s/models.py' % app_name)
  3. app_models_dir_path = self_path / pathlib.Path('%s/models' % app_name)
  4. app_model_modules = []
  5. if app_models_file_path.is_file():
  6. model_module = importlib.import_module('.%s.models' % app_name, 'apps')
  7. app_model_modules = [model_module]
  8. elif app_models_dir_path.is_dir():
  9. app_model_modules = tools.general.get_modules_in_dir(str(app_models_dir_path))
  10. for module in app_model_modules:
  11. if hasattr(module, 'db'):
  12. db_objs.append(module.db)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement