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
If I set up more than one static view, and at least one of them is
under a prefix, the remaining ones will continue to use the first
prefix. So the second one is "/prefix_1/static_2/" when it should be "/
prefix_2/static_2".
The reason for this seems to be because StaticURLInfo keeps the
original config it was called with, so add_route always sees the
original config's route_prefix. I can work around it by manually
updating the StaticURLInfo.config attribute here:
defstatic_include_2(config):
frompyramid.interfacesimportIStaticURLInfoinfo=config.registry.queryUtility(IStaticURLInfo)
info.config=config# info.config.route_prefix = config.route_prefix # this works too config.add_static_view('static_2', '/path/to/static_2')
If I use the same name for both static views, like both "static"
instead of "static_1" and "static_2", there will be a route name
conflict. add_static_view should probably be updated to take the
prefix into account and make sure to use the full path for route
names: "prefix_1/static/" and "prefix_2/static/" #3:
Including debugtoolbar is still causing prefixes to be ignored when
including a function that calls add_static_view. Although basic
includes like this one do still get prefixes applied:
def basic_include(config):
config.add_route('home', '/')
config.add_view(lambda request: Response('hello'),
route_name='home')
I don't know if it's debugtoolbar itself that causes the problem or
something to do with tweens or addons in general, but the toolbar is
the only one I have tried so far.
The text was updated successfully, but these errors were encountered:
About #2, I understand now. In the presence of a route prefix, the name should be nonglobal because it's prefixed by the route prefix in the URL. It's a bit tricky at the moment because we use the name as a global identifier for pyramid.url.static_url (aka request.static_url) API to be able to generate static URLs against individual static views, e.g.:
request.static_url('foo:bar/baz.html')
I'll try to fix it somehow.
I still need some sort of repeatable test case for #3 though.
From the maillist, jazg reports:
Okay I have been experimenting for a while, there are still a few
issues related to add_static_view:
#1:
If I set up more than one static view, and at least one of them is
under a prefix, the remaining ones will continue to use the first
prefix. So the second one is "/prefix_1/static_2/" when it should be "/
prefix_2/static_2".
The reason for this seems to be because StaticURLInfo keeps the
original config it was called with, so add_route always sees the
original config's route_prefix. I can work around it by manually
updating the StaticURLInfo.config attribute here:
#2:
If I use the same name for both static views, like both "static"
instead of "static_1" and "static_2", there will be a route name
conflict. add_static_view should probably be updated to take the
prefix into account and make sure to use the full path for route
names: "prefix_1/static/" and "prefix_2/static/"
#3:
Including debugtoolbar is still causing prefixes to be ignored when
including a function that calls add_static_view. Although basic
includes like this one do still get prefixes applied:
def basic_include(config):
config.add_route('home', '/')
config.add_view(lambda request: Response('hello'),
route_name='home')
I don't know if it's debugtoolbar itself that causes the problem or
something to do with tweens or addons in general, but the toolbar is
the only one I have tried so far.
The text was updated successfully, but these errors were encountered: