These classes can be found in the backend/config.py
file, and should
be customized to your needs.
Configuration options common to all environments.
Configuration options for running in the development environment.
Configuration options for running in the production environment.
Configuration options for running in the test environment.
backend.app.
create_app
()[source]¶Creates a pre-configured Flask application.
Defaults to using backend.config.ProdConfig
, unless the
FLASK_DEBUG
environment variable is explicitly set to “true”,
in which case it uses backend.config.DevConfig
. Also configures
paths for the templates folder and static files.
backend.app.
_create_app
(config_object: backend.config.BaseConfig, **kwargs)[source]¶Creates a Flask application.
Parameters: |
---|
The following methods are all automatically called by backend.app._create_app()
:
backend.app.
configure_app
(app, config_object)[source]¶General application configuration:
backend.magic.
Bundle
(module_name, admin_category_name=None, admin_icon_class=None, admins_module_name=<object object>, commands_module_name=<object object>, command_group_names=<object object>, models_module_name=<object object>, serializers_module_name=<object object>, views_module_name=<object object>, blueprint_names=<object object>)[source]¶A helper class for auto-registering a group of commands, views, models, serializers and admins with the app.
Bundles are organized just as standard Python modules. If you want to customize any of the default names, you can do so in the constructor.
Each bundle’s modules are auto-detected if they exist, and will be registered if so. All are optional.
Simple bundle example:
$ tree
backend/
└── simple/
├── __init__.py
├── admins.py
├── commands.py
├── models.py
├── serializers.py
└── views.py
Big bundle example:
$ tree
backend/
└── big/
├── __init__.py
├── admins
│ ├── __init__.py # must import all ModelAdmin(s)
│ ├── one_admin.py
│ └── two_admin.py
├── commands
│ ├── __init__.py # must import the click group from .group and
│ │ # all commands
│ ├── group.py # the group should have the same name as the
│ │ # bundle's folder, or to change it, pass
│ │ # the command_group_names kwarg to Bundle
│ ├── one.py
│ └── two.py
├── models
│ ├── __init__.py # must import all Model(s)
│ ├── one.py
│ └── two.py
├── serializers
│ ├── __init__.py # must import all ModelSerializer(s)
│ ├── one_serializer.py
│ └── two_serializer.py
└── views
├── __init__.py # must import the Blueprint(s) from .blueprint
│ # and all ModelResource(s)
├── blueprint.py # the blueprint should have the same name as the
│ # bundle's folder, or to change it, pass the
│ # blueprint_names kwarg to Bundle
├── one_resource.py
└── two_resource.py
In both cases, backend/<bundle_folder_name>/__init__.py
is the same:
$ cat backend/<bundle_folder_name>/__init__.py
from backend.magic import Bundle
bundle = Bundle(__name__)
Finally, the bundle modules must be registered in backend/config.py
:
BUNDLES = [
'backend.simple',
'backend.big',
]
Parameters: |
|
---|