add the hook for unknown types also to the cython Packer

This commit is contained in:
Antonio Cuni 2013-10-18 17:46:42 +02:00
parent 5467515065
commit a7485eccb2

View file

@ -176,6 +176,9 @@ cdef class Packer(object):
for v in o:
ret = self._pack(v, nest_limit-1)
if ret != 0: break
elif self.handle_unknown_type(o):
# it means that obj was succesfully packed, so we are done
return 0
elif self._default:
o = self._default(o)
ret = self._pack(o, nest_limit-1)
@ -195,6 +198,9 @@ cdef class Packer(object):
self.pk.length = 0
return buf
def handle_unknown_type(self, obj):
return None
def pack_extended_type(self, typecode, data):
msgpack_pack_ext(&self.pk, typecode, len(data))
msgpack_pack_raw_body(&self.pk, data, len(data))