Adding script name to 'global_config' during application setup #3735
Adding script name to 'global_config' during application setup #3735mmerickel merged 8 commits intoPylons:mainfrom
Conversation
There was a problem hiding this comment.
- 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.bootstrapas 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. |
mmerickel
left a comment
There was a problem hiding this comment.
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_configcan 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.