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
There's some subtle bugs in apps that hit certain APIs during configuration because parts of pyramid rely on threadlocal state that may or may not be available.
The result here is that the translations are still using myapp:locale because add_translation_dirs resolves those asset paths at config-time. Asset overrides work by using custom pkg_resources hooks that only affect pkg_resources when a registry is pushed on the threadlocal stack. Normally this would require surrounding relevant code with config.begin() and config.end(). We've done a poor job of documenting this.
I propose an optional context manager that we can implement easily (we already did something like this for p.paster.bootstrap in #2760) in order to manage the lifecycle.
with Configurator() as config:
config.override_asset(to_override='myapp:locale/', override_with='yourapp:locale/')
config.add_translation_dirs('myapp:locale')
There's some subtle bugs in apps that hit certain APIs during configuration because parts of pyramid rely on threadlocal state that may or may not be available.
An example:
The result here is that the translations are still using
myapp:locale
becauseadd_translation_dirs
resolves those asset paths at config-time. Asset overrides work by using custompkg_resources
hooks that only affectpkg_resources
when a registry is pushed on the threadlocal stack. Normally this would require surrounding relevant code withconfig.begin()
andconfig.end()
. We've done a poor job of documenting this.I propose an optional context manager that we can implement easily (we already did something like this for
p.paster.bootstrap
in #2760) in order to manage the lifecycle.related: #2760 #2046
The text was updated successfully, but these errors were encountered: