David Reiss | 6acc269 | 2010-02-26 00:56:02 +0000 | [diff] [blame^] | 1 | from protocol import TBinaryProtocol |
| 2 | from transport import TTransport |
| 3 | |
| 4 | def serialize(thrift_object, protocol_factory = TBinaryProtocol.TBinaryProtocolFactory()): |
| 5 | transport = TTransport.TMemoryBuffer() |
| 6 | protocol = protocol_factory.getProtocol(transport) |
| 7 | thrift_object.write(protocol) |
| 8 | return transport.getvalue() |
| 9 | |
| 10 | def deserialize(base, buf, protocol_factory = TBinaryProtocol.TBinaryProtocolFactory()): |
| 11 | transport = TTransport.TMemoryBuffer(buf) |
| 12 | protocol = protocol_factory.getProtocol(transport) |
| 13 | base.read(protocol) |
| 14 | return base |
| 15 | |