Package s3 :: Module s3dashboard :: Class S3DashboardWidget
[frames] | no frames]

Class S3DashboardWidget

source code

object --+
         |
        S3DashboardWidget

Base class for dashboard widgets

Instance Methods
 
widget(self, agent_id, config, version=None, context=None)
Construct the XML for this widget
source code
 
get_script_path(self, debug=False)
Get the path to the script file for this widget, can be implemented in subclasses to override the default.
source code
 
configure(self, agent)
Get widget-specific configuration form fields
source code
 
accept_config(self, config, form)
Extract the new config settings from the form and update the config dict
source code
 
validate_config(self, form)
Validation function for configuration form
source code
 
__init__(self, label=None, defaults=None, on_create_agent=None, **options)
Initialize the widget, called when configuring an available widget for the dashboard.
source code
 
create_agent(self, agent_id, config=None, version=None, context=None)
Create an agent for this widget
source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Class Methods
 
inject_script(cls, agent_id, version=None, widget_class="dashboardWidget", options=None)
Helper method to inject the init script for a particular agent, usually called by widget() method.
source code
Static Methods
 
configbar()
Build the widget configuration task bar
source code
Class Variables
  title = "Dashboard Widget"
Properties

Inherited from object: __class__

Method Details

widget(self, agent_id, config, version=None, context=None)

source code 

Construct the XML for this widget

Parameters:
  • agent_id - the agent ID (same as the DOM node ID of the outer wrapper DIV, to attach scripts)
  • config - the active widget configuration
  • version - the config version key
  • context - the S3DashboardContext
Returns:
an XmlComponent with the widget contents, the outer DIV will be added by the agent

get_script_path(self, debug=False)

source code 

Get the path to the script file for this widget, can be implemented in subclasses to override the default.

Parameters:
  • debug - whether running in debug mode or not
Returns:
path relative to static/scripts, None if no separate script file required

configure(self, agent)

source code 

Get widget-specific configuration form fields

Parameters:
  • agent - the agent
Returns:
a list of Fields for the form construction

accept_config(self, config, form)

source code 

Extract the new config settings from the form and update the config dict

Parameters:
  • config - the config dict
  • form - the configuration form
Returns:
the updated config dict (can be a replacement)

NB config must remain JSON-serializable

validate_config(self, form)

source code 

Validation function for configuration form

inject_script(cls, agent_id, version=None, widget_class="dashboardWidget", options=None)
Class Method

source code 

Helper method to inject the init script for a particular agent, usually called by widget() method.

Parameters:
  • agent_id - the agent ID
  • version - the config version key
  • widget_class - the widget class to instantiate
  • options - JSON-serializable dict of options to pass to the widget instance

configbar()
Static Method

source code 

Build the widget configuration task bar

Returns:
the XML for the task bar

__init__(self, label=None, defaults=None, on_create_agent=None, **options)
(Constructor)

source code 

Initialize the widget, called when configuring an available widget for the dashboard.

Parameters:
  • label - a label for this widget type, used in the widget selector in the configuration GUI; if left empty, then the widget type will not appear in the selector
  • defaults - the default configuration for this widget
  • on_create_agent - callback, invoked when an agent is created for this widget:
    • on_create_agent(agent, context)
  • **options - type-specific options
Overrides: object.__init__

create_agent(self, agent_id, config=None, version=None, context=None)

source code 

Create an agent for this widget

Parameters:
  • agent_id - the agent ID
  • config - the agent configuration dict
  • version - the config version key
  • context - the current S3DashboardContext

Class Variable Details

title

Value:
"Dashboard Widget"