'Save this configuration in the database
@param context: the current S3DashboardContext
@param update: widget configurations to update, as dict
{widget_id: {config-dict}}
@return: the new version key, or None if not successful'

def save(self, context, update=None):

    if ((not self.configurable) or (not self.loaded)):
        return None
    db = current.db
    table = current.s3db.s3_dashboard
    widgets = self.active_widgets
    configs = []
    for widget in widgets:
        widget_id = widget.get('widget_id')
        new_config = update.get(widget_id)
        if new_config:
            new_config['widget_id'] = widget_id
            configs.append(new_config)
        else:
            configs.append(widget)
    version = uuid.uuid4().get_hex()
    config_id = self.config_id
    if (not config_id):
        data = {'controller': context.controller, 'function': context.function, 'version': version, 'next_id': self.next_id, 'active': True, 'widgets': configs}
        config_id = table.insert(**data)
        if (not config_id):
            version = None
    else:
        data = {'version': version, 'next_id': self.next_id, 'widgets': configs}
        success = db((table.id == config_id)).update(**data)
        if (not success):
            version = None
    if version:
        self.version = version
    return version
