diff options
author | Jenkins <jenkins@review.openstack.org> | 2015-04-17 19:10:47 +0000 |
---|---|---|
committer | Gerrit Code Review <review@openstack.org> | 2015-04-17 19:10:47 +0000 |
commit | 2df5edaa9b260e2695de950dcd57b61df4b6e85c (patch) | |
tree | 35a39798ead99013460e7aa4133d5ce1ec40b13d | |
parent | c89aed35f06328b773a75b32ed236e5e9d2a8e1d (diff) | |
parent | 58c1f290803e1939dabcc5847c0ae9441690b98a (diff) | |
download | oslo-serialization-2df5edaa9b260e2695de950dcd57b61df4b6e85c.tar.gz |
Merge "Add docstring(s) to handler registry(s)"
-rw-r--r-- | oslo_serialization/msgpackutils.py | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/oslo_serialization/msgpackutils.py b/oslo_serialization/msgpackutils.py index b4bbbf4..fa055f7 100644 --- a/oslo_serialization/msgpackutils.py +++ b/oslo_serialization/msgpackutils.py @@ -40,6 +40,17 @@ UnpackException = msgpack.UnpackException class HandlerRegistry(object): + """Registry of *type* specific msgpack handlers extensions. + + See: https://github.com/msgpack/msgpack/blob/master/spec.md#formats-ext + + Do note that due to the current limitations in the msgpack python + library we can not *currently* dump/load a tuple without converting + it to a list. + + This may be fixed in: https://github.com/msgpack/msgpack-python/pull/100 + """ + # Applications can assign 0 to 127 to store # application-specific type information... min_value = 0 @@ -53,6 +64,7 @@ class HandlerRegistry(object): return six.itervalues(self._handlers) def register(self, handler): + """Register a extension handler to handle its associated type.""" if self.frozen: raise ValueError("Frozen handler registry can't be modified") ident = handler.identity @@ -73,9 +85,11 @@ class HandlerRegistry(object): return len(self._handlers) def get(self, identity): + """Get the handle for the given numeric identity (or none).""" return self._handlers.get(identity, None) def match(self, obj): + """Match the registries handlers to the given object (or none).""" for handler in six.itervalues(self._handlers): if isinstance(obj, handler.handles): return handler @@ -268,8 +282,20 @@ def _create_default_registry(): return registry -#: Default, read-only/frozen registry that will be used when none is provided. default_registry = _create_default_registry() +""" +Default, read-only/frozen registry that will be used when none is provided. + +This registry has msgpack extensions for the following: + +* ``DateTime`` objects. +* ``Date`` objects. +* ``UUID`` objects. +* ``itertools.count`` objects/iterators. +* ``set`` and ``frozenset`` container(s). +* ``netaddr.IPAddress`` objects (only if ``netaddr`` is importable). +* ``xmlrpclib.DateTime`` datetime objects. +""" def load(fp, registry=None): |