Re: Custom Class Serialization with Serpent.
Irmen de Jong <[email protected]> Tue, 17 Dec 2013 01:07:04 +0100
| Newsgroups | gmane.comp.python.pyro |
|---|---|
| Message-ID | <[email protected]> |
On 16-12-2013 16:37, Abhishek Dwaraki wrote:
> Hey Christian,
> Thank you for the guidance. In the time that I had since I posted
> my query, I did exactly what you suggested. I converted it to a string representation
> and then just to be on the safer side, reconverted the literals to their respective
> types on the receiving end. I am still getting the unserializable class protocol error.
>
> I will recreate the scenario and send out the error traceback from my console in a bit.
> Thank you for your guidance.
Serpent by itself is perfectly able to serialize the IPv4 object (albeit into a dict, it
does that with most custom classes):
>>> import serpent, ipaddress
>>> i=ipaddress.IPv4Address("1.2.3.4")
>>> s=serpent.dumps(i)
>>> print(serpent.loads(s))
{'_ip': 16909060, '_max_prefixlen': 32, '_version': 4, '__class__': 'IPv4Address'}
>>>
The 'problem' is that the deserialization routine in Pyro itself (dict_to_class) only
recognizes a limited set of custom classes to reconstruct. This is on purpose.
The fact that you can not yet customize this default behavior is recognised in this
enhancement: https://github.com/irmen/Pyro4/issues/16
Pull requests are gladly accepted ;-)
Irmen
------------------------------------------------------------------------------
Rapidly troubleshoot problems before they affect your business. Most IT
organizations don't have a clear picture of how application performance
affects their revenue. With AppDynamics, you get 100% visibility into your
Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro!
http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk