Base class for all enum field types
This class should not be directly instantiated. Instead subclass it and set AUTO_TYPE to be a SomeEnum() where SomeEnum is a subclass of Enum.
Dict which coerces its values
Dict implementation which overrides all element-adding methods and coercing the element(s) being added to the required element type
List which coerces its elements
List implementation which overrides all element-adding methods and coercing the element(s) being added to the required element type
Set which coerces its values
Dict implementation which overrides all element-adding methods and coercing the element(s) being added to the required element type
Descriptor allowing us to assign pinning data as a dict of key_types
This allows us to have an object field that will be a dict of key_type keys, allowing that will convert back to string-keyed dict.
This will take care of the conversion while the dict field will make sure that we store the raw json-serializable data on the object.
key_type should return a type that unambiguously responds to six.text_type so that calling key_type on it yields the same thing.
Anonymous enum field type
This class allows for anonymous enum types to be declared, simply by passing in a list of valid values to its constructor. It is generally preferrable though, to create an explicit named enum type by sub-classing the BaseEnumField type directly.
A string field type that may contain sensitive (password) information.
Passwords in the string value are masked when stringified.
Field type that masks passwords when the field is stringified.
A mixin that can be applied to an EnumField to enforce a state machine
e.g: Setting the code below on a field will ensure an object cannot transition from ERROR to ACTIVE
class FakeStateMachineField(fields.EnumField, fields.StateMachine):
ACTIVE = ‘ACTIVE’ PENDING = ‘PENDING’ ERROR = ‘ERROR’ DELETED = ‘DELETED’
- ALLOWED_TRANSITIONS = {
- ACTIVE: {
- PENDING, ERROR, DELETED,
}, PENDING: {
ACTIVE, ERROR}, ERROR: {
PENDING,}, DELETED: {} # This is a terminal state
}
_TYPES = (ACTIVE, PENDING, ERROR, DELETED)
UUID Field Type
Warning
This class does not actually validate UUIDs. This will happen in a future major version of oslo.versionedobjects
To validate that you have valid UUIDs you need to do the following in your own objects/fields.py
Example: |
and then in your objects use <your_projects>.object.fields.UUIDField. |
---|
This will become default behaviour in the future.