I think set_default_connection is a bit misleading, in that it "tries to create a connection from the environment"... To put this in pseudo-code:
defget_default_connection():
connection=<somepre-loadedconnectionalreadystored>ifnotconnection:
connection=<createaconnectionsomehowfromtheenvironment>ifnotconnection:
connection=<createaconnectionfromtheenvironmentanotherway>ifnotconnection:
raiseEnvironmentError('Connection cannot be inferred from the environment :(')
returnconnectiondefset_default_connection(connection=None):
<somesafeplacetostoreaconnection>=connection# Yes, this could be None.The idea being...
set_default_connection() sets a variable, that's all.get_default_connection() goes through a list of possible ways to get a connection, raising an exception when we can't get one...
What we have today is:
set_default_connection() sets a variable and tries to come up with a magical connection from the environment if possible.get_default_connection() only returns the variable
I'm sure this will be subject to a bunch of debate, but having a getter method also doing some setting seems really misleading to me.
I think
set_default_connectionis a bit misleading, in that it "tries to create a connection from the environment"... To put this in pseudo-code:The idea being...
set_default_connection()sets a variable, that's all.get_default_connection()goes through a list of possible ways to get a connection, raising an exception when we can't get one...What we have today is:
set_default_connection()sets a variable and tries to come up with a magical connection from the environment if possible.get_default_connection()only returns the variableI'm sure this will be subject to a bunch of debate, but having a getter method also doing some setting seems really misleading to me.