views:

80

answers:

1

I'm trying to return a django object in a XML-RPC response. Is it possible to serialize a model as XML-RPC methodResponse?

A: 

I did figure out how serialize with xmlrpclib.dumps

def get_model(uuid):
    o = MyModel.objects.get(uuid=uuid)
    return xmlrpclib.dumps((o, ), allow_none=True, methodresponse=1)

This will result in a XML-RPC methodResponse. Then on the client end I just need to use xmlrpclib.loads to convert to a python native object.

got_model = rpc_srv.getmodel('f21e4e0b-493a-460b-982a-d2bb31c45864')
m, method = xmlrpclib.loads(got_model)
for item in m:
    print item
John Giotta