Common internal object model
oslo_versionedobjects.base.
ComparableVersionedObject
¶Mix-in to provide comparison methods
When objects are to be compared with each other (in tests for example), this mixin can be used.
oslo_versionedobjects.base.
ObjectListBase
(*args, **kwargs)¶Mixin class for lists of objects.
This mixin class can be added as a base class for an object that is implementing a list of objects. It adds a single field of ‘objects’, which is the list store, and behaves like a list itself. It supports serialization of the list of objects automatically.
oslo_versionedobjects.base.
TimestampedObject
¶Mixin class for db backed objects with timestamp fields.
Sqlalchemy models that inherit from the oslo_db TimestampMixin will include these fields and the corresponding objects will benefit from this mixin.
oslo_versionedobjects.base.
VersionedObject
(context=None, **kwargs)¶Base class and object factory.
This forms the base of all objects that can be remoted or instantiated via RPC. Simply defining a class that inherits from this base class will make it remotely instantiatable. Objects should implement the necessary “get” classmethod routines as well as “save” object methods as appropriate.
obj_attr_is_set
(attrname)¶Test object to see if attrname is present.
Returns True if the named attribute has a value set, or False if not. Raises AttributeError if attrname is not a valid attribute for this object.
obj_class_from_name
(objname, objver)¶Returns a class from the registry based on a name and version.
obj_clone
()¶Create a copy.
obj_from_primitive
(primitive, context=None)¶Object field-by-field hydration.
obj_get_changes
()¶Returns a dict of changed fields and their new values.
obj_load_attr
(attrname)¶Load an additional attribute from the real object.
This should load self.$attrname and cache any data that might be useful for future load operations.
obj_make_compatible
(primitive, target_version)¶Make an object representation compatible with a target version.
This is responsible for taking the primitive representation of an object and making it suitable for the given target_version. This may mean converting the format of object attributes, removing attributes that have been added since the target version, etc. In general:
Parameters: |
|
---|---|
Raises: |
|
obj_name
()¶Return the object’s name
Return a canonical name for this object which will be used over the wire for remote hydration.
obj_reset_changes
(fields=None, recursive=False)¶Reset the list of fields that have been changed.
Parameters: |
|
---|
This is NOT “revert to previous values”.
Specifying fields on recursive resets will only be honored at the top level. Everything below the top will reset all.
obj_to_primitive
(target_version=None, version_manifest=None)¶Simple base-case dehydration.
This calls to_primitive() for each item in fields.
obj_what_changed
()¶Returns a set of fields that have been modified.
save
(context)¶Save the changed fields back to the store.
This is optional for subclasses, but is presented here in the base class for consistency among those that do.
oslo_versionedobjects.base.
VersionedObjectDictCompat
¶Mix-in to provide dictionary key access compatibility
If an object needs to support attribute access using dictionary items instead of object attributes, inherit from this class. This should only be used as a temporary measure until all callers are converted to use modern attribute access.
oslo_versionedobjects.base.
VersionedObjectSerializer
¶A VersionedObject-aware Serializer.
This implements the Oslo Serializer interface and provides the ability to serialize and deserialize VersionedObject entities. Any service that needs to accept or return VersionedObjects as arguments or result values should pass this to its RPCClient and RPCServer objects.
OBJ_BASE_CLASS
¶alias of VersionedObject
deserialize_entity
(context, entity)¶Deserialize something from primitive form.
Parameters: |
|
---|---|
Returns: | Deserialized form of entity |
serialize_entity
(context, entity)¶Serialize something to primitive form.
Parameters: |
|
---|---|
Returns: | Serialized form of entity |
oslo_versionedobjects.base.
obj_make_list
(context, list_obj, item_cls, db_list, **extra_args)¶Construct an object list from a list of primitives.
This calls item_cls._from_db_object() on each item of db_list, and adds the resulting object to list_obj.
:param:context: Request context :param:list_obj: An ObjectListBase object :param:item_cls: The VersionedObject class of the objects within the list :param:db_list: The list of primitives to convert to objects :param:extra_args: Extra arguments to pass to _from_db_object() :returns: list_obj
oslo_versionedobjects.base.
obj_tree_get_versions
(objname, tree=None)¶Construct a mapping of dependent object versions.
This method builds a list of dependent object versions given a top- level object with other objects as fields. It walks the tree recursively to determine all the objects (by symbolic name) that could be contained within the top-level object, and the maximum versions of each. The result is a dict like:
{'MyObject': '1.23', ... }
Parameters: |
|
---|---|
Returns: | A dictionary of object names and versions |
oslo_versionedobjects.base.
remotable
(fn)¶Decorator for remotable object methods.
oslo_versionedobjects.base.
remotable_classmethod
(fn)¶Decorator for remotable classmethods.
Except where otherwise noted, this document is licensed under Creative Commons Attribution 3.0 License. See all OpenStack Legal Documents.