djblets.extensions.staticfiles¶
-
class
ExtensionStaticStorage
(extension, *args, **kwargs)[source]¶ Bases:
django.core.files.storage.FileSystemStorage
Provides access to static files owned by an extension.
This is a thin wrapper around FileSystemStorage that determines the path to the static directory within the extension. It will only operate on files within that path.
-
class
ExtensionFinder
(*args, **kwargs)[source]¶ Bases:
django.contrib.staticfiles.finders.BaseFinder
Finds static files within enabled extensions.
ExtensionFinder can list static files belonging to an extension, and find the path of a static file, given an extension ID and path.
All static files are expected to be in the form of
ext/<extension_id>/<path>
, whereextension_id
is the ID given to an extension (based on the full class path for the extension class).An extension is only valid if it has a “static” directory.
-
storage_class
[source]¶ alias of
ExtensionStaticStorage
-
-
class
PackagingCachedFilesStorage
(*args, **kwargs)[source]¶ Bases:
pipeline.storage.PipelineCachedStorage
Looks up referenced static files from the current storage.
When one static file references another, Django assumes that the referenced file is in the same static storage and path as that of the parent. This prevents a bundled file (such as a .less file) in an extension from referencing an image or other file shipped with the main application.
This storage works around this by attempting to look up a storage matching the referenced path. If found, the paths from that storage will be used instead.
This behavior is only activated when Django performs a lookup as the result of a
.css
containing aurl(...)
or@import ...
.-
hashed_name
(name, content=None)[source]¶ Look up and generate a hashed filename for the given filename.
This will attempt to find a storage that serves up the given filename. If found, the hashed data from that storage will be used instead.
If not found, then this falls back to the default functionality of either generating a hashed filename from the parent static file’s storage, or raising an exception about a missing file.
Parameters: Returns: - A resulting file path for the file, with a hash in the
filename.
Return type:
-
-
class
PackagingStorage
(storage=None, *args, **kwargs)[source]¶ Bases:
pipeline.finders.PipelineFinder
Looks up stored files when packaging an extension.
This is a special Pipeline static file storage implementation that can locate the proper Storage class when trying to find a file.
This works just like PipelineFinder, but can interface with PackagingFinder to trigger a lookup across all storages, since PackagingFinder by default limits to the extension’s static files.
-
class
PackagingFinder
(apps=None, *args, **kwargs)[source]¶ Bases:
django.contrib.staticfiles.finders.FileSystemFinder
Finds static media files for an extension.
This is used during packaging to list only static media files provided by the extension, but to allow looking up static media from all apps.
It works with PackagingStorage to do the appropriate lookup given the parameters passed.
Essentially, when collecting static media (using the collectstatic management command), Django will call list() on the finders, grabbing every known static file, and packaging those. For extensions, we don’t want to grab media files from the main apps, and want to limit only to the files bundled with the extension.
There are times when we do want to list all files, though. For example, when referencing definitions files provided by the project for .less files.
In the default case, PackagingFinder.list will only look up files from the extension, but if given an extra parameter that PackagingStorage can pass (used for finding referenced files), it will look through all storages.
-
storage_class
[source]¶ alias of
PackagingStorage
-