Laurent DAVERIO
unread,May 1, 2013, 12:41:56 PM5/1/13Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to pylons-...@googlegroups.com
Hello list,
sorry for asking such a newbie question (and making you work on May Day
;-), but I can't seem to find the answer by myself... :-(
I have a Pyramid app defining a few static routes, e.g. :
> for d in ('css', 'img', 'js'):
> config.add_static_view('%s' % d, 'mypkg:static/%s' % d, cache_max_age=3600)
This allows me to use static assets in my templates, e.g.:
> <img src="${request.static_url('mypkg:static/img/%s' % img_filename}" />
Now, I would like to test in my view if "img_filename" corresponds to an
existing file.
Is there an easy way to get the physical file path from the asset
specification ? Of course, I don't want to hardcode the image directory
path in my code, and I'd also like to avoid having to add a new setting
("image_dir=...") to my development.ini.
Many thanks in advance,
Laurent.