How does Pyramid's add_static_view work?

Viewed 2988

How does add_static_view(name, path) in Pyramid work?

From the docstring:

"The name argument is a string representing an application-relative local URL prefix. It may alternately be a full URL. The path argument is the path on disk where the static files reside. This can be an absolute path, a package-relative path, or an asset specification."

Somehow I have got the impression that this description is not very accurate.

If I add some code along the lines of

config.add_static_view("static", "/path/to/resource/on/filesystem")

and I visit

http://localhost:PORT/static/logo.png  

I see the logo.png given that it can be found in

/path/to/resource/on/filesystem/

Now, if I have some code like the following

config.add_static_view("http://myfilehoster.com/images", "myproject:images")

the description that "the path argument is the path on disk where the static files reside" does not seem accurate anymore because the actual files reside on the disk of myfilehoster. It seems to me that I am merely registering some kind of identifier (myproject:images) that I can use within my program code to reference the "real" location "http://myfilehoster.com/images". E.g.

request.static_url("myproject:images/logo.png") 

would be resolved to "http://myfilehoster.com/images/logo.png".

So is the documentation inaccurate here or am I missing something?

1 Answers
Related