• Get Review Board
  • What's New
  • Products
  • Review Board Code review, image review, and document review
  • Documentation
  • Release Notes
  • Power Pack Enterprise integrations, reports, and enhanced document review
  • Try for 60 Days
  • Purchase
  • RBCommons Review Board as a Service, hosted by us
  • Pricing
  • RBTools Command line tools and Python API for Review Board
  • Documentation
  • Release Notes
  • Review Bot Automated code review, connecting tools you already use
  • Documentation
  • Release Notes
  • RB Gateway Manage Git and Mercurial repositories in your network
  • Documentation
  • Release Notes
  • Learn and Explore
  • What is Code Review?
  • Documentation
  • Frequently Asked Questions
  • Support Options
  • Third-Party Integrations
  • Demo
  • Review Board RBTools Power Pack Review Bot Djblets RB Gateway
    1. Djblets 5.x
    2. Version 5.x
    3. Version 4.x
    4. Version 3.x
    5. Version 2.x
    6. Version 2.0
    7. Version 1.0
    8. Version 0.9
    9. Djblets Documentation
    10. Module and Class References
    11. djblets.extensions.staticfiles
  • Home
  • Guides
  • Avatar Services Guides
  • Writing Avatar Services
  • Extension Guides
  • Writing Extensions
  • Testing Extensions
  • Feature Checks Guides
  • Introduction to Feature Checks
  • Writing Features
  • Writing Feature Checkers
  • Testing with Feature Checks
  • Integration Guides
  • Supporting Integrations
  • Writing Integrations
  • Privacy Compliance Guides
  • Getting and Checking Consent
  • Working with Personally Identifiable Information
  • Service Integrations
  • reCAPTCHA Guides
  • Using reCAPTCHA
  • Registries Guides
  • Writing Registries
  • Web API Guides
  • Writing Web API Resources
  • Adding OAuth2 Support
  • Module and Class References
  • djblets
  • djblets.deprecation
  • djblets.auth.forms
  • djblets.auth.ratelimit
  • djblets.auth.signals
  • djblets.auth.util
  • djblets.auth.views
  • djblets.avatars.errors
  • djblets.avatars.forms
  • djblets.avatars.registry
  • djblets.avatars.services
  • djblets.avatars.services.base
  • djblets.avatars.services.fallback
  • djblets.avatars.services.file_upload
  • djblets.avatars.services.gravatar
  • djblets.avatars.services.url
  • djblets.avatars.settings
  • djblets.cache.backend
  • djblets.cache.backend_compat
  • djblets.cache.context_processors
  • djblets.cache.errors
  • djblets.cache.forwarding_backend
  • djblets.cache.serials
  • djblets.cache.synchronizer
  • djblets.conditions
  • djblets.conditions.choices
  • djblets.conditions.conditions
  • djblets.conditions.errors
  • djblets.conditions.operators
  • djblets.conditions.values
  • djblets.configforms.forms
  • djblets.configforms.mixins
  • djblets.configforms.pages
  • djblets.configforms.registry
  • djblets.configforms.views
  • djblets.datagrid.grids
  • djblets.db.backends.mysql.base
  • djblets.db.fields
  • djblets.db.fields.base64_field
  • djblets.db.fields.comma_separated_values_field
  • djblets.db.fields.counter_field
  • djblets.db.fields.json_field
  • djblets.db.fields.modification_timestamp_field
  • djblets.db.fields.relation_counter_field
  • djblets.db.managers
  • djblets.db.query
  • djblets.db.query_catcher
  • djblets.db.query_comparator
  • djblets.db.validators
  • djblets.extensions.admin
  • djblets.extensions.errors
  • djblets.extensions.extension
  • djblets.extensions.forms
  • djblets.extensions.hooks
  • djblets.extensions.loaders
  • djblets.extensions.manager
  • djblets.extensions.middleware
  • djblets.extensions.models
  • djblets.extensions.packaging
  • djblets.extensions.resources
  • djblets.extensions.settings
  • djblets.extensions.signals
  • djblets.extensions.staticfiles
  • djblets.extensions.testing
  • djblets.extensions.testing.testcases
  • djblets.extensions.urls
  • djblets.extensions.views
  • djblets.extensions.templatetags.djblets_extensions
  • djblets.features
  • djblets.features.checkers
  • djblets.features.decorators
  • djblets.features.errors
  • djblets.features.feature
  • djblets.features.level
  • djblets.features.registry
  • djblets.features.testing
  • djblets.features.templatetags.features
  • djblets.forms.fields
  • djblets.forms.fieldsets
  • djblets.forms.forms
  • djblets.forms.forms.key_value_form
  • djblets.forms.widgets
  • djblets.gravatars
  • djblets.gravatars.templatetags.gravatars
  • djblets.http.middleware
  • djblets.http.responses
  • djblets.integrations.errors
  • djblets.integrations.forms
  • djblets.integrations.hooks
  • djblets.integrations.integration
  • djblets.integrations.manager
  • djblets.integrations.mixins
  • djblets.integrations.models
  • djblets.integrations.urls
  • djblets.integrations.views
  • djblets.log
  • djblets.log.middleware
  • djblets.log.siteconfig
  • djblets.log.urls
  • djblets.log.views
  • djblets.mail.dmarc
  • djblets.mail.message
  • djblets.mail.testing
  • djblets.mail.utils
  • djblets.markdown
  • djblets.markdown.extensions.escape_html
  • djblets.markdown.extensions.wysiwyg
  • djblets.markdown.extensions.wysiwyg_email
  • djblets.pipeline.compilers.es6
  • djblets.pipeline.compilers.less
  • djblets.pipeline.compilers.mixins
  • djblets.pipeline.compilers.rollup
  • djblets.pipeline.compilers.typescript
  • djblets.pipeline.settings
  • djblets.privacy.consent
  • djblets.privacy.consent.base
  • djblets.privacy.consent.common
  • djblets.privacy.consent.errors
  • djblets.privacy.consent.forms
  • djblets.privacy.consent.hooks
  • djblets.privacy.consent.registry
  • djblets.privacy.consent.tracker
  • djblets.privacy.models
  • djblets.privacy.pii
  • djblets.privacy.templatetags.djblets_privacy
  • djblets.recaptcha.mixins
  • djblets.recaptcha.siteconfig
  • djblets.recaptcha.templatetags.djblets_recaptcha
  • djblets.recaptcha.widgets
  • djblets.registries
  • djblets.registries.errors
  • djblets.registries.importer
  • djblets.registries.mixins
  • djblets.registries.registry
  • djblets.registries.signals
  • djblets.secrets
  • djblets.secrets.crypto
  • djblets.secrets.token_generators
  • djblets.secrets.token_generators.base
  • djblets.secrets.token_generators.legacy_sha1
  • djblets.secrets.token_generators.registry
  • djblets.secrets.token_generators.vendor_checksum
  • djblets.siteconfig
  • djblets.siteconfig.admin
  • djblets.siteconfig.context_processors
  • djblets.siteconfig.django_settings
  • djblets.siteconfig.forms
  • djblets.siteconfig.managers
  • djblets.siteconfig.middleware
  • djblets.siteconfig.models
  • djblets.siteconfig.signals
  • djblets.siteconfig.views
  • djblets.template.caches
  • djblets.template.context
  • djblets.template.loaders.conditional_cached
  • djblets.template.loaders.namespaced_app_dirs
  • djblets.testing.decorators
  • djblets.testing.testcases
  • djblets.testing.testrunners
  • djblets.urls.context_processors
  • djblets.urls.decorators
  • djblets.urls.patterns
  • djblets.urls.resolvers
  • djblets.urls.root
  • djblets.urls.staticfiles
  • djblets.util.compat.django.core.cache
  • djblets.util.compat.python.past
  • djblets.util.contextmanagers
  • djblets.util.dates
  • djblets.util.decorators
  • djblets.util.filesystem
  • djblets.util.functional
  • djblets.util.html
  • djblets.util.http
  • djblets.util.humanize
  • djblets.util.json_utils
  • djblets.util.properties
  • djblets.util.serializers
  • djblets.util.symbols
  • djblets.util.templatetags.djblets_deco
  • djblets.util.templatetags.djblets_email
  • djblets.util.templatetags.djblets_forms
  • djblets.util.templatetags.djblets_images
  • djblets.util.templatetags.djblets_js
  • djblets.util.templatetags.djblets_utils
  • djblets.util.typing
  • djblets.util.views
  • djblets.views.generic.base
  • djblets.views.generic.etag
  • djblets.webapi.auth
  • djblets.webapi.auth.backends
  • djblets.webapi.auth.backends.api_tokens
  • djblets.webapi.auth.backends.base
  • djblets.webapi.auth.backends.basic
  • djblets.webapi.auth.backends.oauth2_tokens
  • djblets.webapi.auth.views
  • djblets.webapi.decorators
  • djblets.webapi.encoders
  • djblets.webapi.errors
  • djblets.webapi.fields
  • djblets.webapi.managers
  • djblets.webapi.models
  • djblets.webapi.oauth2_scopes
  • djblets.webapi.resources
  • djblets.webapi.resources.base
  • djblets.webapi.resources.group
  • djblets.webapi.resources.registry
  • djblets.webapi.resources.root
  • djblets.webapi.resources.user
  • djblets.webapi.resources.mixins.api_tokens
  • djblets.webapi.resources.mixins.forms
  • djblets.webapi.resources.mixins.oauth2_tokens
  • djblets.webapi.resources.mixins.queries
  • djblets.webapi.responses
  • djblets.webapi.signals
  • djblets.webapi.testing
  • djblets.webapi.testing.decorators
  • djblets.webapi.testing.testcases
  • General Index
  • Python Module Index
  • Release Notes
  • djblets.extensions.staticfiles¶

    Support for looking up static files in extensions.

    class ExtensionStaticStorage(*args, **kwargs)[source]¶

    Bases: 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.

    source_dir = 'static'[source]¶
    prefix = None[source]¶
    __init__(extension: Extension, *args, **kwargs) → None[source]¶

    Initialize the static files storage for an extension.

    This will build a path for the extension’s static directory and set it, whether it exists or not.

    Parameters:
    • extension (djblets.extensions.extension.Extension) – The extension the static files storage is bound to.

    • *args (tuple) – Positional arguments to pass to the parent class.

    • **kwargs (dict) – Keyword arguments to pass to the parent class.

    class ExtensionFinder(*args, **kwargs)[source]¶

    Bases: 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>, where extension_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

    __init__(*args, **kwargs)[source]¶
    find(path, all=False)[source]¶

    Finds the real path to a static file, given a static path.

    The path must start with “ext/<extension_id>/”. The files within will map to files within the extension’s “static” directory.

    class PackagingCachedFilesStorage(*args, **kwargs)[source]¶

    Bases: PipelineStorage

    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 a url(...) or @import ....

    __init__(*args, **kwargs)[source]¶
    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:
    • name (str) – The name of the file to look up.

    • content (str) – The content of the file, if known.

    Returns:

    A resulting file path for the file, with a hash in the

    filename.

    Return type:

    str

    __annotations__ = {}¶
    class PackagingStorage(storage=None, *args, **kwargs)[source]¶

    Bases: 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.

    find_storage(name)[source]¶
    __annotations__ = {}¶
    class PackagingFinder(app_names=None, *args, **kwargs)[source]¶

    Bases: 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

    extension_static_dir: Optional[str] = None¶

    The path to the extension static directory.

    This is set during packaging to collect static media files from the extension.

    Type:

    str

    __annotations__ = {'extension_static_dir': 'Optional[str]'}¶

    Keep up with the latest Review Board releases, security updates, and helpful information.

    About
    News
    Demo
    RBCommons Hosting
    Integrations
    Happy Users
    Support Options
    Documentation
    FAQ
    User Manual
    RBTools
    Administration Guide
    Power Pack
    Release Notes
    Downloads
    Review Board
    RBTools
    Djblets
    Power Pack
    Package Store
    PGP Signatures
    Contributing
    Bug Tracker
    Submit Patches
    Development Setup
    Wiki
    Follow Us
    Mailing Lists
    Reddit
    Twitter
    Mastodon
    Facebook
    YouTube

    Copyright © 2006-2025 Beanbag, Inc. All rights reserved.

    Terms of Service — Privacy Policy — AI Ethics Policy — Branding

    On this page

    • [Top]
    • ExtensionStaticStorage
      • ExtensionStaticStorage.source_dir
      • ExtensionStaticStorage.prefix
      • ExtensionStaticStorage.__init__()
    • ExtensionFinder
      • ExtensionFinder.storage_class
      • ExtensionFinder.__init__()
      • ExtensionFinder.find()
    • PackagingCachedFilesStorage
      • PackagingCachedFilesStorage.__init__()
      • PackagingCachedFilesStorage.hashed_name()
      • PackagingCachedFilesStorage.__annotations__
    • PackagingStorage
      • PackagingStorage.find_storage()
      • PackagingStorage.__annotations__
    • PackagingFinder
      • PackagingFinder.storage_class
      • PackagingFinder.extension_static_dir
      • PackagingFinder.__annotations__