File tree Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -31,6 +31,7 @@ def create_app_factory(
3131 blueprints = None ,
3232 converter_entry_points = None ,
3333 converters = None ,
34+ init_functions_entry_points = None ,
3435 wsgi_factory = None ,
3536 ** app_kwargs ,
3637):
@@ -125,6 +126,13 @@ def _create_app(**kwargs):
125126 entry_points = blueprint_entry_points ,
126127 modules = blueprints ,
127128 )
129+
130+ # Load init functions
131+ init_functions_loader (
132+ app ,
133+ entry_points = init_functions_entry_points ,
134+ )
135+
128136
129137 app_loaded .send (_create_app , app = app )
130138
@@ -178,6 +186,20 @@ def cli(**params):
178186 return cli
179187
180188
189+ def init_functions_loader (app , entry_points = None ):
190+ """Run functions that should be executed after the application is instantiated.
191+
192+ :param entry_points: List of entry points providing to Flask extensions.
193+
194+ .. versionadded: 2.0.0
195+ """
196+ def loader_init_func (func ):
197+ with app .app_context ():
198+ func (app )
199+
200+ _loader (app , loader_init_func , entry_points = entry_points )
201+
202+
181203def app_loader (app , entry_points = None , modules = None ):
182204 """Run default application loader.
183205
You can’t perform that action at this time.
0 commit comments