Exemplo n.º 1
0
def get_object_as_msgpack(o, cls=None, ignore_wrappers=False, complex_as=dict, encoding="utf8", polymorphic=False):
    if cls is None:
        cls = o.__class__

    prot = MessagePackDocument(ignore_wrappers=ignore_wrappers, complex_as=complex_as, polymorphic=polymorphic)
    ctx = FakeContext(out_document=[prot._object_to_doc(cls, o)])
    prot.create_out_string(ctx, encoding)
    return "".join(ctx.out_string)
Exemplo n.º 2
0
def get_object_as_msgpack_doc(o, cls=None, ignore_wrappers=False,
                                            complex_as=dict, polymorphic=False):
    if cls is None:
        cls = o.__class__

    prot = MessagePackDocument(ignore_wrappers=ignore_wrappers,
                                 complex_as=complex_as, polymorphic=polymorphic)

    return prot._object_to_doc(cls, o)
Exemplo n.º 3
0
def get_object_as_msgpack(o, cls=None, ignore_wrappers=False, complex_as=dict,
                                            encoding='utf8', polymorphic=False):
    if cls is None:
        cls = o.__class__

    prot = MessagePackDocument(ignore_wrappers=ignore_wrappers,
                                 complex_as=complex_as, polymorphic=polymorphic)
    ctx = FakeContext(out_document=[prot._object_to_doc(cls,o)])
    prot.create_out_string(ctx, encoding)
    return b''.join(ctx.out_string)