When running an Esmerald application, by design the application instance parameters take priority to the ones in the settings. Settings are an alternative but complementary way for Esmerald.
What I want is to unify both. Meaning, when I access the settings, even if I passed parameters via application instance, I need to be able to do setting.app_name
, for example, and also see the value passed via Esmerald(app_name="my app")
.
What we currently have
Create an Esmerald object
from esmerald import Esmerald
app = Esmerald(app_name="My new application", summary="The esmerald app")
When I want to access the value of the app_name:
from esmerald.conf import settings, get, request
@get('/home')
async def home(request: Request) -> str:
print(request.app.app_name) # "my app"
print(request.app.settings.app_name) # "Esmerald". The default value in the settings
print(settings.app_name) # "Esmerald". The default value in the settings
What we want
When I want to access the value of the app_name:
from esmerald.conf import settings, get, request
@get('/home')
async def home(request: Request) -> str:
print(request.app.app_name) # "my app"
print(request.app.settings.app_name) # "my app"
print(settings.app_name) # "my app"
From release 0.7.+
This functionality was added