websauna.system.http.static module¶
Registering static assets with cache busting policies.
For more information read Static assets narrative.
-
class
websauna.system.http.static.
CollectedStaticCacheBuster
(static_view_name, path, settings)[source]¶ Bases:
object
A Pyramid cache buster which uses persistent static item folder from ws-collect-static command to serve static assets.
-
class
websauna.system.http.static.
CopyAndHashCollector
(root, settings, target_path=None)[source]¶ Bases:
object
Toss all static files into perma-asset folder, MD5 hash included in the name.
-
collect
(root, static_view_name, entry, relative_path)[source]¶ Process one file and add it to our collection.
-
finish
()[source]¶ Finish collection and create manifest.json file.
- Return type
- Returns
Collected files.
-
get_permanent_path
(root, static_view_name, relative_path, hash)[source]¶ Return the permanent path for an asset.
-
-
class
websauna.system.http.static.
DefaultStaticAssetPolicy
(config)[source]¶ Bases:
websauna.system.http.static.StaticAssetPolicy
Default inplementation of StaticAssetPolicy.
-
add_static_view
(name, path)[source]¶ Include a path in static assets and configures cache busting for it.
This does not only include the static resources in the routing, but sets the default cache busting policy for them in the production environment.
See
pyramid.config.Configurator.add_static_view()
andwebsauna.system.Initializer.add_cache_buster()
-
collect_static
()[source]¶ Collect all static files from all static views for the manifest.
- Return type
- Returns
Collect assets.
-
views
= None¶ Maintain registry of all registered static views
-
-
websauna.system.http.static.
MANIFEST_FILE
= '.manifest.json'¶ Generated at the root of each perma-asset folder
-
class
websauna.system.http.static.
StaticAssetPolicy
(config)[source]¶ Bases:
abc.ABC
A helper class to add static views and apply a configured cache busting policy on them.
-
abstract
add_static_view
(name, path)[source]¶ Include a path in static assets and configures cache busting for it.
This does not only include the static resources in the routing, but sets the default cache busting policy for them in the production environment.
See
pyramid.config.Configurator.add_static_view()
for more details.
-
abstract