Re: Custom Class Serialization with Serpent.

Abhishek Dwaraki <[email protected]> Mon, 16 Dec 2013 22:34:58 -0500
Newsgroups gmane.comp.python.pyro
Message-ID <[email protected]>
Hey Irmen,
                 I agree that the problem lies with the deserialization. But should the same behavior happen when I am not using IPAddress? Rather, I am using a custom class composed of primitives, if you may call them that. I see the deserialization error even on a class that contains just integers and strings.

Regards,
Abhishek.

P.S : And I will definitely take a look at building something. :) (if my limited knowledge of Python permits)

On Dec 16, 2013, at 7:07 PM, Irmen de Jong <[email protected]> wrote:

> 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
> _______________________________________________
> Pyro-core mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/pyro-core


------------------------------------------------------------------------------
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