The oslo_reports.models.base Module

Provides the base report model

This module defines a class representing the basic report data model from which all data models should inherit (or at least implement similar functionality). Data models store unserialized data generated by generators during the report serialization process.

class oslo_reports.models.base.ReportModel(data=None, attached_view=None)

Bases: _abcoll.MutableMapping

A Report Data Model

A report data model contains data generated by some generator method or class. Data may be read or written using dictionary-style access, and may be read (but not written) using object-member-style access. Additionally, a data model may have an associated view. This view is used to serialize the model when str() is called on the model. An appropriate object for a view is callable with a single parameter: the model to be serialized.

If present, the object passed in as data will be transformed into a standard python dict. For mappings, this is fairly straightforward. For sequences, the indices become keys and the items become values.

Parameters:
  • data – a sequence or mapping of data to associate with the model
  • attached_view – a view object to attach to this model
set_current_view_type(tp, visited=None)

Set the current view type

This method attempts to set the current view type for this model and all submodels by calling itself recursively on all values, traversing intervening sequences and mappings when possible, and ignoring all other objects.

Parameters:
  • tp – the type of the view (‘text’, ‘json’, ‘xml’, etc)
  • visited – a set of object ids for which the corresponding objects have already had their view type set