You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
from pyramid.config import Configurator
def main(global_config, **settings):
config = Configurator()
config.include('myapp.myconfig.includeme')
# global_config.get("__script__") = either "prequest", "pserve", "pshell" or None
# signals how the application startup was triggered
# if required handle application setup accordingly
I can provide a pull request if there a no objections. And the code change should have no impact on existings applications.
The text was updated successfully, but these errors were encountered:
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.
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.
The text was updated successfully, but these errors were encountered: