-
Notifications
You must be signed in to change notification settings - Fork 888
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding script name to 'global_config' during application setup #3735
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- could you please tweak these to use
config_vars.setdefault('__script__', 'pshell')
as a simpler one-liner? - Is there a way to make this work with
pyramid.paster.bootstrap
as well, or only the scripts? I believe this use case is not addressed here and was the topic of the recent mailing list posts triggering this work. I'm thinking__script__ == 'bootstrap'
in that case.
1: no problem. 2: |
It could be the default value going back to your logic that won’t set it if already defined. Then individual scripts can still override it as you’re doing? |
The scripts (except pserve, prequest) call I had a look at the email discussion and pyramid code again. The original question was if there is way to have more infos in the context of the |
The user would need to forward the setting from global _config into their app but at least it’s an automatic setting versus one they have to set/maintain in their config files. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the status of this from your perspective @adroullier? Trying to understand if you think this is done or if there's still a plan to handle the bootstrap case. I still think we should define __script__
if bootstrap is used directly, not just via these p* scripts.
Rest of the PR looks great and I'd be happy to merge it.
Sorry I haven't mentioned it in my last comment. I can also add the code to set the name to 'bootstrap', like
|
Well the goal is to still add that so the app can differentiate the scenario from a normal startup using that |
Fixes #3734. |
This code extends pyramid startup scripts in python/bin directory (pserve, prequest, pshell, pviews, proutes, ptweens) with additional info about the calling script. The additional info is passed to the **main(global_config, settings) function as part of global_config dict during wsgi setup as 'script'.
global_config
can contain custom values loaded from the ini file, so to avoid unwanted overwriting of a existing 'script' value I've added a extra condition for comapatibility.In some cases it makes sense to call different code whether the application is created as server (bin/pserve) or for a single request (bin/prequest). For example setting up internal caching modules, maintenance or other background functions.