How does add_static_view(name, path) in Pyramid work?
From the docstring:
"Theargument is a string representing an application-relative
local URL prefix. It may alternately be a full URL.
Theargument is the path on disk where the static files
reside. This can be an absolute path, a package-relative path,
or an asset specification."
You are missing something. In the narrative documentation on static assets it states:
Instead of representing a URL prefix, the
nameargument of a call to
add_static_view()can alternately be a URL. Each of examples we’ve seen so far have shown usage of the
nameargument as a URL prefix. However, when
nameis a URL, static assets can be served from an external webserver. In this mode, the
nameis used as the URL prefix when generating a URL using
In the API documentation similar wording is used:
add_static_viewis called with a
nameargument that represents a URL prefix, as it is above, subsequent calls to
pyramid.request.Request.static_url()with paths that start with the
pathargument passed to
add_static_viewwill generate a URL something like
http://<Pyramid app URL>/images/logo.png, which will cause the
logo.pngfile in the images subdirectory of the
mypackagepackage to be served.
Using a URL switches the behaviour of
add_static_view altogether and the
path argument is interpreted as a symbolic path only for the
.static_url() method. That latter detail is perhaps not described as explicitly in the documentation, you could file an issue in the pyramid issue tracker if you feel strongly about that.