Contains the core classes and functionality that makes Horizon what it is. This module is considered internal, and should not be relied on directly.
Public APIs are made available through the horizon module and the classes contained therein.
Bases: horizon.base.Registry, horizon.base.HorizonComponent
A base class for defining Horizon dashboards.
All Horizon dashboards should extend from this base class. It provides the appropriate hooks for automatic discovery of Panel modules, automatically constructing URLconfs, and providing role-based access control.
The name of the dashboard. This will be displayed in the auto-generated navigation and various other places. Default: ''.
A unique “short name” for the dashboard. The slug is used as a component of the URL path for the dashboard. Default: ''.
The panels attribute can be either a flat list containing the name of each panel module which should be loaded as part of this dashboard, or a list of PanelGroup classes which define groups of panels as in the following example:
class SystemPanels(horizon.PanelGroup):
slug = "syspanel"
name = _("System Panel")
panels = ('overview', 'instances', ...)
class Syspanel(horizon.Dashboard):
panels = (SystemPanels,)
Automatically generated navigation will use the order of the modules in this attribute.
Default: [].
Warning
The values for this attribute should not correspond to the name attributes of the Panel classes. They should be the names of the Python modules in which the panel.py files live. This is used for the automatic loading and registration of Panel classes much like Django’s ModelAdmin machinery.
Panel modules must be listed in panels in order to be discovered by the automatic registration mechanism.
The name of the panel which should be treated as the default panel for the dashboard, i.e. when you visit the root URL for this dashboard, that’s the panel that is displayed. Default: None.
A list of role names, all of which a user must possess in order to access any panel registered with this dashboard. This attribute is combined cumulatively with any roles required on individual Panel classes.
A list of service names, all of which must be in the service catalog in order for this dashboard to be available.
Optional path to a URLconf of additional views for this dashboard which are not connected to specific panels. Default: None.
Optional boolean to control whether or not this dashboard should appear in automatically-generated navigation. Default: True.
Optional boolean that indicates whether or not this dashboard includes support for projects/tenants. If set to True this dashboard’s navigation will include a UI element that allows the user to select project/tenant. Default: False.
Boolean value to determine whether this dashboard can be viewed without being logged in. Defaults to False.
Returns the default URL for this dashboard.
The default URL is defined as the URL pattern with name="index" in the URLconf for the Panel specified by default_panel.
Returns the specified Panel instance registered with this dashboard.
Returns the Panel instances registered with this dashboard in order, without any panel groupings.
Bases: object
Bases: horizon.base.Site
A singleton implementation of Site such that all dealings with horizon get the same instance no matter what. There can be only one.
Bases: django.utils.functional.SimpleLazyObject
Bases: exceptions.Exception
Bases: horizon.base.HorizonComponent
A base class for defining Horizon dashboard panels.
All Horizon dashboard panels should extend from this class. It provides the appropriate hooks for automatically constructing URLconfs, and providing role-based access control.
The name of the panel. This will be displayed in the auto-generated navigation and various other places. Default: ''.
A unique “short name” for the panel. The slug is used as a component of the URL path for the panel. Default: ''.
A list of service names, all of which must be in the service catalog in order for this panel to be available.
Path to a URLconf of views for this panel using dotted Python notation. If no value is specified, a file called urls.py living in the same package as the panel.py file is used. Default: None.
The nav attribute can be either boolean value or a callable which accepts a RequestContext object as a single argument to control whether or not this panel should appear in automatically-generated navigation. Default: True.
The name argument for the URL pattern which corresponds to the index view for this Panel. This is the view that Panel.get_absolute_url() will attempt to reverse.
Returns the default URL for this panel.
The default URL is defined as the URL pattern with name="index" in the URLconf for this panel.
Bases: object
A container for a set of Panel classes.
When iterated, it will yield each of the Panel instances it contains.
A unique string to identify this panel group. Required.
A user-friendly name which will be used as the group heading in places such as the navigation. Default: None.
A list of panel module names which should be contained within this grouping.
Bases: object
Bases: horizon.base.Registry, horizon.base.HorizonComponent
The overarching class which encompasses all dashboards and panels.
Returns the default URL for Horizon’s URLconf.
The default URL is determined by calling get_absolute_url() on the Dashboard instance returned by get_default_dashboard().
Returns an ordered tuple of Dashboard modules.
Orders dashboards according to the "dashboards" key in settings.HORIZON_CONFIG or else returns all registered dashboards in alphabetical order.
Any remaining Dashboard classes registered with Horizon but not listed in settings.HORIZON_CONFIG['dashboards'] will be appended to the end of the list alphabetically.
Returns the default Dashboard instance.
If "default_dashboard" is specified in settings.HORIZON_CONFIG then that dashboard will be returned. If not, the first dashboard returned by get_dashboards() will be returned.
Returns the default URL for a particular user.
This method can be used to customize where a user is sent when they log in, etc. By default it returns the value of get_absolute_url().
An alternative function can be supplied to customize this behavior by specifying a either a URL or a function which returns a URL via the "user_home" key in settings.HORIZON_CONFIG. Each of these would be valid:
{"user_home": "/home",} # A URL
{"user_home": "my_module.get_user_home",} # Path to a function
{"user_home": lambda user: "/" + user.name,} # A function
This can be useful if the default dashboard may not be accessible to all users.
Bases: object