Closed adroullier closed 8 months ago
I don't currently have a good vision on how this would be implemented - if it can be done in pyramid's shell scripts directly, and/or if plaster/plaster-pastedeploy would need to assist in some way but I'm happy to consider a PR to add this idea of marshaling a value through into the global_config.
Fixed via https://github.com/Pylons/pyramid/pull/3735.
Pyramid startup scripts in python/bin directory (pserve, prequest, pshell) do not pass any special info to the wsgi app or "main()" function. As far as I know there is no way to find out how the wsgi application startup is triggered.
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.
Right now you have use extra environment variables, multiple wsgi configurations or other workarounds which are not really elegant solutions.
My proposal is to extend the scripts with additional context information which simply refer to the scripts name. The additional info is passed to the main function as part of
global_config["__script__"]
dict during wsgi setup.For example, from a developers perspective it would look like:
I can provide a pull request if there a no objections. And the code change should have no impact on existings applications.