How do I get the absolute path for static assets ? The reason I need
the absolute path is to determine the last modified time of a specific
file so I can append it to my static resources like JS and CSS files.
I wrote a Mako template def like this but it fails at : here =
You will need to use the pkg_resources api from the Python stdlib.
Currently (this will be fixed in 1.3) there is no public API for computing
paths.
import pkg_resources
asset_path = 'mypackage:static/favicon.ico'
package, file = asset_path.split(':', 1)
abs_path =
That worked. Thanks !
Jay
On 11/16/11 5:46 PM, Michael Merickel wrote:
You will need to use the pkg_resources api from the Python stdlib.
Currently (this will be fixed in 1.3) there is no public API for
computing paths.
import pkg_resources
asset_path = 'mypackage:static/favicon.ico'