So what about images in CSS files? I can't use helper functions there... I'll try the h.url_for() in the templates and let you know
On Jan 22, 1:34 pm, "Mike Orr" <[EMAIL PROTECTED]> wrote: > On Jan 22, 2008 11:11 AM, Matt Haggard <[EMAIL PROTECTED]> wrote: > > > > > > > I've got an app with the following ini: > > ... > > [app:main] > > use = egg:myapp > > filter-with = app-prefix > > ... > > [filter:app-prefix] > > use = egg:PasteDeploy#prefix > > prefix=/myapp > > > I've been developing without the filter option, and now that I have > > it, my hard-coded image paths no longer work. (e.g. they're looking > > athttp://127.0.0.1:5000/images/something.gifwhen they should be > > looking athttp://127.0.0.1:5000/myapp/images/something.gif) > > > So, is there some helper (or config option that could let me write my > > own helper) that I can use in my templates for image urls? > > > I wonder if a helper's the solution, though... because I reference > > images in my css file... and those image urls should work too. > > > Is there a way to have requests to /images/something.gif go an get the > > images? Do I need to make a route, then a controller to serve up > > images? I'm thinking this is a common enough problem that there would > > be a more apparent solution. > > Ideally you'd use h,url_for for this, and it would automatically > adjust the URLs. However, the current version of Routes does not > properly handle routes to the public directory (which are neither > regular routes nor "static named routes"). This will be improved in > the next version. In the meantime, you may be able to get by with: > > h.url_for("images/something.gif") > > but there's a possibility it may choose the wrong route and generate a > different URL. > > Check back here if that doesn't work. > > Why do you need the prefix? Are you combining this app with other > Pylons or Paste applications in the same site? If so, are they > sharing the same process or each in their own processes? Or is this > the only Python application in the site? Depending on your situation, > I think there's a Python confing variable that sets the prefix without > you having to use the convoluted app-prefix filter. The only time you > absolutely have to use that filter is when combining multiple Paste > applications in the same process. > > -- > Mike Orr <[EMAIL PROTECTED]> --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
