'Lazy property to instantiate the dashboard agents
@return: a dict {agent_id: agent}'

@property
def agents(self):

    agents = self._agents
    if (agents is None):
        config = self.config
        context = self.context
        config_id = config.config_id
        available_widgets = config.available_widgets
        next_id = config.next_id
        agents = self._agents = {}
        for (index, widget_config) in enumerate(config.active_widgets):
            name = widget_config.get('widget')
            widget = available_widgets.get(name)
            if (not widget):
                continue
            if (config_id is None):
                widget_id = next_id
            else:
                widget_id = widget_config.get('widget_id')
                if (widget_id is None):
                    widget_id = next_id
            next_id = max(next_id, (widget_id + 1))
            widget_config['widget_id'] = widget_id
            agent_id = ('db-widget-%s' % widget_id)
            if (not agent_id):
                continue
            agent = widget.create_agent(agent_id, config=widget_config, version=config.version, context=context)
            agents[agent_id] = agent
        config.next_id = next_id
    return agents
