camptocamp / pyramid_closure

Helpers for working with the Closure tools in a Pyramid project
0 stars 4 forks source link

Use request.static_url in mako templates #15

Open fredj opened 9 years ago

fredj commented 9 years ago

http://docs.pylonsproject.org/docs/pyramid/en/latest/narr/assets.html#static-assets-section

elemoine commented 9 years ago

I'm no longer clear on the advantages of using static_url (or static_path) for generating static URLs. What do you think?

Also, for example, if we want to generate a static URL for

"/node_modules/angular-gettext/dist/angular-gettext.js"

we will have to use something like this:

"${request.static_path('%s/angular-gettext/dist/angular-gettext.js' % request.registry.settings.get('node_modules_path'))}"

which is not very convenient. And I don't see what it gives us really.

Interested in your opinion about this.

elemoine commented 9 years ago

This is what the Pyramid docs say:

« One benefit of using the static_url() function rather than constructing static URLs "by hand" is that if you need to change the name of a static URL declaration, the generated URLs will continue to resolve properly after the rename. »

I'm not convinced. What about the case where the file system path (instead of the name of the static view) changes? In that case you're a in better situation if you constructed your URL "by hand".

fredj commented 9 years ago

I'm not convinced either but absolute paths may cause some issue when the project will be served by apache: the "base url" may be something like: http://www.example.com/fredj/test/ and the absolute paths will no longer work