@@ -892,28 +892,29 @@ def engine(self):
892
892
is used this might raise a :exc:`RuntimeError` if no application is
893
893
active at the moment.
894
894
"""
895
- return self .get_engine (self . get_app () )
895
+ return self .get_engine ()
896
896
897
- def make_connector (self , app , bind = None ):
897
+ def make_connector (self , app = None , bind = None ):
898
898
"""Creates the connector for a given state and bind."""
899
- return _EngineConnector (self , app , bind )
899
+ return _EngineConnector (self , self . get_app ( app ) , bind )
900
900
901
- def get_engine (self , app , bind = None ):
902
- """Returns a specific engine.
901
+ def get_engine (self , app = None , bind = None ):
902
+ """Returns a specific engine."""
903
+
904
+ app = self .get_app (app )
905
+ state = get_state (app )
903
906
904
- .. versionadded:: 0.12
905
- """
906
907
with self ._engine_lock :
907
- state = get_state (app )
908
908
connector = state .connectors .get (bind )
909
+
909
910
if connector is None :
910
911
connector = self .make_connector (app , bind )
911
912
state .connectors [bind ] = connector
913
+
912
914
return connector .get_engine ()
913
915
914
916
def get_app (self , reference_app = None ):
915
- """Helper method that implements the logic to look up an application.
916
- """
917
+ """Helper method that implements the logic to look up an application."""
917
918
if reference_app is not None :
918
919
return reference_app
919
920
if self .app is not None :
0 commit comments