• 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 0.9
    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.extension
  • Home
  • Guides
  • Extension Guides
  • Writing Extensions
  • Testing Extensions
  • Web API Guides
  • Writing Web API Resources
  • Module and Class References
  • djblets
  • djblets.auth.forms
  • djblets.auth.signals
  • djblets.auth.util
  • djblets.auth.views
  • djblets.cache.backend
  • djblets.cache.backend_compat
  • djblets.cache.context_processors
  • djblets.cache.errors
  • djblets.cache.forwarding_backend
  • djblets.cache.serials
  • djblets.configforms.forms
  • djblets.configforms.pages
  • djblets.configforms.views
  • djblets.datagrid.grids
  • djblets.db.backends.mysql.base
  • djblets.db.fields
  • djblets.db.managers
  • djblets.db.query
  • djblets.db.validators
  • 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.feedview.views
  • djblets.feedview.templatetags.feedtags
  • djblets.forms.fields
  • djblets.gravatars
  • djblets.gravatars.templatetags.gravatars
  • 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.wysiwyg
  • djblets.markdown.extensions.wysiwyg_email
  • djblets.siteconfig.context_processors
  • djblets.siteconfig.django_settings
  • djblets.siteconfig.forms
  • djblets.siteconfig.managers
  • djblets.siteconfig.middleware
  • djblets.siteconfig.models
  • djblets.siteconfig.views
  • 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.contextmanagers
  • djblets.util.dates
  • djblets.util.decorators
  • djblets.util.filesystem
  • djblets.util.http
  • djblets.util.humanize
  • djblets.util.serializers
  • djblets.util.views
  • 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.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.views
  • djblets.webapi.decorators
  • djblets.webapi.encoders
  • djblets.webapi.errors
  • djblets.webapi.managers
  • djblets.webapi.models
  • 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.queries
  • djblets.webapi.responses
  • djblets.webapi.testing
  • djblets.webapi.testing.decorators
  • djblets.webapi.testing.testcases
  • djblets
  • djblets.auth.forms
  • djblets.auth.signals
  • djblets.auth.util
  • djblets.auth.views
  • djblets.cache.backend
  • djblets.cache.backend_compat
  • djblets.cache.context_processors
  • djblets.cache.errors
  • djblets.cache.forwarding_backend
  • djblets.cache.serials
  • djblets.configforms.forms
  • djblets.configforms.pages
  • djblets.configforms.views
  • djblets.datagrid.grids
  • djblets.db.backends.mysql.base
  • djblets.db.fields
  • djblets.db.managers
  • djblets.db.query
  • djblets.db.validators
  • 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.feedview.views
  • djblets.feedview.templatetags.feedtags
  • djblets.forms.fields
  • djblets.gravatars
  • djblets.gravatars.templatetags.gravatars
  • 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.wysiwyg
  • djblets.markdown.extensions.wysiwyg_email
  • djblets.siteconfig.context_processors
  • djblets.siteconfig.django_settings
  • djblets.siteconfig.forms
  • djblets.siteconfig.managers
  • djblets.siteconfig.middleware
  • djblets.siteconfig.models
  • djblets.siteconfig.views
  • 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.contextmanagers
  • djblets.util.dates
  • djblets.util.decorators
  • djblets.util.filesystem
  • djblets.util.http
  • djblets.util.humanize
  • djblets.util.serializers
  • djblets.util.views
  • 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.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.views
  • djblets.webapi.decorators
  • djblets.webapi.encoders
  • djblets.webapi.errors
  • djblets.webapi.managers
  • djblets.webapi.models
  • 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.queries
  • djblets.webapi.responses
  • djblets.webapi.testing
  • djblets.webapi.testing.decorators
  • djblets.webapi.testing.testcases
  • General Index
  • Python Module Index
  • Release Notes
  • This documentation covers Djblets 0.9. You can select a version above or view the latest documentation.

    djblets.extensions.extension¶

    class JSExtension(extension)[source]¶

    Bases: object

    Base class for a JavaScript extension.

    This can be subclassed to provide the information needed to initialize a JavaScript extension.

    The JSExtension subclass is expected to define a model_class attribute naming its JavaScript counterpart. This would be the variable name for the (uninitialized) model for the extension, defined in a JavaScript bundle.

    It may also define apply_to, which is a list of URL names that the extension will be initialized on. If not provided, the extension will be initialized on all pages.

    To provide additional data to the model instance, the JSExtension subclass can implement get_model_data() and return a dictionary of data to pass. You may also override the get_settings() method to return, a dict of settings to the model_class. By default, the associated extension’s settings are returned.

    model_class = None[source]¶

    The name of the JavaScript model class to instantiate.

    This class will be instantiated on the page. It should be a subclass of Djblets.Extension().

    apply_to = None[source]¶

    The list of URL names to load this extension on.

    If not provided, this will be loaded on all pages.

    __init__(extension)[source]¶

    Initialize the JavaScript extension.

    Parameters:extension (Extension) – The main extension that owns this JavaScript extension.
    applies_to(url_name)[source]¶

    Return whether this extension applies to the given URL name.

    Parameters:url_name (unicode) – The name of the URL.
    Returns:True if this JavaScript extension should load on the page with the given URL name. False if it should not load.
    Return type:bool
    get_model_data(request, **kwargs)[source]¶

    Return model data for the Extension model instance in JavaScript.

    Subclasses can override this to return custom data to pass to the extension class defined in model_class. This data must be JSON-serializable.

    Parameters:request (django.http.HttpRequest) – The HTTP request from the client.
    Returns:Model data to pass to the constructor of the JavaScript extension class.
    Return type:dict
    get_settings()[source]¶

    Return the settings for the JS Extension.

    By default, this is the associated Extension object’s settings. Subclasses may override this method to provide different settings.

    These settings will be provided to the model_class as a settings key in its initialization options.

    Returns:The extension settings.
    Return type:dict
    class Extension(extension_manager)[source]¶

    Bases: object

    Base class for an extension.

    Extensions must subclass this class. They’ll automatically have support for settings, adding hooks, and plugging into the administration UI.

    For information on writing extensions, see Writing Extensions.

    admin_site¶

    django.contrib.admin.AdminSite – The database administration site set for the extension. This will be set automatically if has_admin_site` is True.

    extension_manager¶

    djblets.extensions.manager.ExtensionManager – The extension manager that manages this extension.

    hooks¶

    set of djblets.extensions.hooks.ExtensionHook – The hooks currently registered and enabled for the extension.

    middleware_instances¶

    list of object – The list of Django middleware instances. Each will be an instance of a class listed in middleware.

    settings¶

    djblets.extensions.settings.Settings – The settings for the extension.

    metadata = None[source]¶

    Metadata describing the package.

    This is used to set the name, version, and other information for the extension. This data defaults to coming from the extension’s Python package metadata, but can be set on the extension itself. You would want to use this if shipping multiple extensions in a single package, if you want to include a space in the package name, or if you want the version to be set independently of the package, for example.

    The following keys are supported:

    • Name: The displayed name of the extension.
    • Version: The version of the extension.
    • Summary: A summary of the extension.
    • Description: A more detailed description of the extension.
    • License: The license the extension was released under.
    • Author: The name of the author writing/maintaining the extension.
    • Author-email: The e-mail address of the author writing/maintaining the extension.
    • Author-home-page: The URL of the author writing/maintaining the extension.
    • Home-page: The URL of the extension’s home/product/company page.
    is_configurable = False[source]¶

    Whether or not the extension is user-configurable.

    If True, the extension will have a Configure link in the extension list that will take the user to a page for modifying extension settings. The extension must provide a admin_urls.py file defining a top-level URL (^$) pointing to a view that will handle configuration.

    default_settings = {}[source]¶

    Default settings for the extension.

    These values will be used when looking up keys in settings that don’t have custom values saved in the database.

    has_admin_site = False[source]¶

    Whether or not the extension has a database administration site.

    If True, the extension will have a Database link in the extension list that will take the user to a page for adding/editing any database models registered by the extension.

    requirements = [][source]¶

    A list of any extension IDs to enable when this extension is enabled.

    This is used to ensure that another extension is enabled before this one. It’s primarily for extensions that are augmenting or depending on another extension’s functionality.

    resources = [][source]¶

    A list of API resource instances offered by this extension.

    Each entry in the list is an instance of a custom WebAPIResource. These resources will appear underneath the extension’s own resource.

    apps = [][source]¶

    A list of Django application module paths to load.

    Each of these will be added to INSTALLED_APPS while the extension is enabled. It follows the same format as that setting.

    context_processors = [][source]¶

    A list of Django context processors to load.

    Each of these will be added to TEMPLATE_CONTEXT_PROCESSORS while the extension is enabled. It follows the same format as that setting.

    middleware = [][source]¶

    A list of Django middleware to load.

    Each of these will be added to MIDDLEWARE_CLASSES while the extension is enabled. It follows the same format as that setting.

    css_bundles = {}[source]¶

    A dictionary of CSS bundles to include in the package.

    These will be automatically packaged along with the extension, and can be loaded in templates using {% ext_css_bundle %}.

    Each key in the dictionary is the name of the bundle, and the value is a dictionary containing a source_filenames key pointing to a list of CSS/LessCSS files.

    A special bundle ID of default will cause the CSS to be loaded on every page.

    js_bundles = {}[source]¶

    A dictionary of JavaScript bundles to include in the package.

    These will be automatically packaged along with the extension, and can be loaded in templates using {% ext_js_bundle %}.

    Each key in the dictionary is the name of the bundle, and the value is a dictionary containing a source_filenames key pointing to a list of JavaScript files.

    A special bundle ID of default will cause the JavaScript to be loaded on every page.

    js_extensions = [][source]¶

    A list of JavaScript extension classes to enable on pages.

    Each entry in the list is a JSExtension subclass to load.

    __init__(extension_manager)[source]¶

    Initialize the extension.

    Subclasses should not override this. Instead, they should override initialize().

    Parameters:extension_manager (djblets.extensions.manager.ExtensionManager) – The extension manager that manages this extension.
    initialize()[source]¶

    Initialize the extension.

    Subclasses can override this to provide any custom initialization. They do not need to call the parent function, as it does nothing.

    shutdown()[source]¶

    Shut down the extension.

    By default, this calls shutdown_hooks.

    Subclasses should override this if they need custom shutdown behavior.

    shutdown_hooks()[source]¶

    Shut down all hooks for the extension.

    get_bundle_id(name)[source]¶

    Return the ID for a CSS or JavaScript bundle.

    This ID should be used when manually referencing the bundle in a template. The ID will be unique across all extensions.

    Parameters:name (unicode) – The name of the bundle to reference.
    Returns:The ID of the bundle corresponding to the name.
    Return type:unicode
    admin_urlconf[source]¶

    The module defining URLs for the extension’s admin site.

    class ExtensionInfo(ext_class, package_name, metadata={})[source]¶

    Bases: object

    Information on an extension.

    This class stores the information and metadata on an extension. This includes the name, version, author information, where it can be downloaded, whether or not it’s enabled or installed, and anything else that may be in the Python package for the extension.

    encodings = [u’utf-8’, ‘US-ASCII’, u’latin1’][source]¶
    classmethod create_from_entrypoint(entrypoint, ext_class)[source]¶

    Create a new ExtensionInfo from a Python EntryPoint.

    This will pull out information from the EntryPoint and return a new ExtensionInfo from it.

    It handles pulling out metadata from the older PKG-INFO files and the newer METADATA files.

    Parameters:
    • entrypoint (pkg_resources.EntryPoint) – The EntryPoint pointing to the extension class.
    • ext_class (type) – The extension class (subclass of Extension).
    Returns:

    An ExtensionInfo instance, populated with metadata from the package.

    Return type:

    ExtensionInfo

    __init__(ext_class, package_name, metadata={})[source]¶

    Instantiate the ExtensionInfo using metadata and an extension class.

    This will set information about the extension based on the metadata provided by the caller and the extension class itself.

    Parameters:
    • ext_class (type) – The extension class (subclass of Extension).
    • package_name (unicode) – The package name owning the extension.
    • metadata (dict, optional) – Optional metadata for the extension. If the extension provides its own metadata, that will take precedence.
    Raises:

    TypeError – The parameters passed were invalid (they weren’t a new-style call or a legacy entrypoint-related call).

    __unicode__()[source]¶
    __str__()[source]¶

    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]