44. PYRAMID.CONFIG
When add_static_view is |
called |
with |
a |
name |
argument |
that represents a URL prefix, |
as it is |
above, |
subsequent |
calls |
to |
pyramid.request.Request.static_url() with |
paths |
that |
start |
with the path argument passed to add_static_view will generate a URL something like http://<Pyramid app URL>/images/logo.png, which will cause the logo.png file in the images subdirectory of the mypackage package to be served.
add_static_view can alternately be used with a name argument which is a URL, causing static assets to be served from an external webserver. This happens when the name argument is a fully qualified URL (e.g. starts with http:// or similar). In this mode, the name is used as the prefix of the full URL when generating a URL using pyramid.request.Request.static_url(). For example, if add_static_view is called like so:
add_static_view(’http://example.com/images’, ’mypackage:images/’)
Subsequently, the URLs generated by pyramid.request.Request.static_url() for that static view will be prefixed with http://example.com/images:
static_url(’mypackage:images/logo.png’, request)
When add_static_view is called with a |
name argument |
that |
is the URL http://example.com/images, |
subsequent |
calls |
to |
pyramid.request.Request.static_url() |
with paths |
that |
start |
with the path argument passed to add_static_view will generate a URL something like http://example.com/logo.png. The external webserver listening on example.com must be itself configured to respond properly to such a request.
See Serving Static Assets for more information.
add_view(view=None, name=’‘, for_=None, permission=None, request_type=None, route_name=None, request_method=None, request_param=None, containment=None, attr=None, renderer=None, wrapper=None, xhr=False, accept=None, header=None, path_info=None, custom_predicates=(), context=None, decorator=None, mapper=None, http_cache=None,
match_param=None)
Add a view configuration to the current configuration state. Arguments to