File: examples.rst

package info (click to toggle)
python-oslo.versionedobjects 3.8.0-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 720 kB
  • sloc: python: 5,669; makefile: 24; sh: 2
file content (21 lines) | stat: -rw-r--r-- 1,037 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
==========
 Examples
==========

IOT lightbulb
=============

Full source located at https://opendev.org/openstack/oslo.versionedobjects/oslo_versionedobjects/examples/iot_bulb.py.

.. literalinclude:: ../../../oslo_versionedobjects/examples/iot_bulb.py
    :language: python
    :linenos:
    :lines: 14-

Expected (or similar) output::

	The __str__() output of this new object: IOTLightbulb(manufactured_on=2017-03-15T23:25:01Z,serial='abc-123')
	The 'serial' field of the object: abc-123
	Primitive representation of this object: {'versioned_object.version': '1.0', 'versioned_object.changes': ['serial', 'manufactured_on'], 'versioned_object.name': 'IOTLightbulb', 'versioned_object.data': {'serial': u'abc-123', 'manufactured_on': '2017-03-15T23:25:01Z'}, 'versioned_object.namespace': 'versionedobjects.examples'}
	The __str__() output of this new (reconstructed) object: IOTLightbulb(manufactured_on=2017-03-15T23:25:01Z,serial='abc-123')
	After serial number change, the set of fields that have been mutated is: set(['serial'])