You'll want to avoid changing the path in your usage of static_url. Fortunately, Pyramid supports overriding static assets, so you can make a dummy path and override that with your dev or production "real" asset path.
config.add_static_view('images', 'p_started:webapp/images') config.override_asset(to_override='p_started:webapp/images/', override_with='p_started:webapp/dist/images') request.static_url('p_started:webapp/images/pyramid.png') On Sat, Aug 16, 2014 at 3:23 PM, davide moro <davide.m...@gmail.com> wrote: > > > > 2014-08-16 6:59 GMT+02:00 Karl O. Pinc <k...@meme.com>: >> >> Hello, >> >> On 08/15/2014 05:39:51 PM, davide moro wrote: >> > Is there a way to generate a static url using the name "images" >> > registered >> > in add_static_view? >> > I mean: >> > >>> ${request.static_url('p_started:images/pyramid.png')} >> > instead of: >> > >>> ${request.static_url('p_started:webapp/app/images/ >> > pyramid.png')} >> > I want to use the name because the path will change depending on the >> > deployment settings. >> >> I don't know how to do what you want, and am not particularly >> experienced with pyramid. But if the path changes based >> on deployment settings why not use the deployment settings >> value everywhere and make that relationship explicit? >> >> In the .ini: >> >> minify=app >> >> Then in the code: >> >> config.add_static_view('images', >> , 'p_started:webapp/' >> + config.registry.settings['minifiy'] >> + '/images' >> , cache_max_age=3601) >> >> >> And: >> >> >> ${request.static_url('p_started:images/' >> + request.registry.settings['minifiy'] >> + '/images') > > > Hi Karl! > > Thank you for your tips, I hoped to avoid this workaround. > > Anyway for me it sounds like a weird behaviour of static_url. I'm not sure > but probably its parameter should be bound to the name registered in > add_static_view because: > * if you want to construct a url you should know the exact path associated > to the name (webapp/app/images) > * if you change the path of your assets you'll have to change all your > templates code > * when you construct by hand an url of a static resource you just digit > http://localhost:6543/images/pyramid.png and not webapp/app/etc > > Or not? What do you think about that? > > Thank you! > > davide > > -- > You received this message because you are subscribed to the Google Groups > "pylons-devel" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to pylons-devel+unsubscr...@googlegroups.com. > To post to this group, send email to pylons-devel@googlegroups.com. > Visit this group at http://groups.google.com/group/pylons-devel. > For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups "pylons-devel" group. To unsubscribe from this group and stop receiving emails from it, send an email to pylons-devel+unsubscr...@googlegroups.com. To post to this group, send email to pylons-devel@googlegroups.com. Visit this group at http://groups.google.com/group/pylons-devel. For more options, visit https://groups.google.com/d/optout.