On Sep 4, 6:11 pm, jazg <[email protected]> wrote: > Okay I have been experimenting for a while, there are still a few > issues related to add_static_view: > > #1: > > """ > from pyramid.config import Configurator > from paste.httpserver import serve > > def static_include_1(config): > config.add_static_view('static_1', '/path/to/static_1') > > def static_include_2(config): > config.add_static_view('static_2', '/path/to/static_2') > > if __name__ == '__main__': > config = Configurator() > config.include(static_include_1, route_prefix='prefix_1') > config.include(static_include_2, route_prefix='prefix_2') > serve(config.make_wsgi_app()) > """ > > 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: > > def static_include_2(config): > from pyramid.interfaces import IStaticURLInfo > info = 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') > > #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.
Can you create an issue at https://github.com/Pylons/pyramid/issues so this doesn't get dropped on the floor? -- You received this message because you are subscribed to the Google Groups "pylons-discuss" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en.
