Re: Pyro-core Digest, Vol 87, Issue 1

Plamen Dimitrov <[email protected]> Sat, 05 Jul 2014 16:45:48 +0300
Newsgroups gmane.comp.python.pyro
Message-ID <[email protected]>
On 07/04/2014 11:45 PM, pyro-core-request-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org wrote:
> Subject:
> Re: [Pyro] Serializing attributes and indexing
> From:
> Irmen de Jong <[email protected]>
> Date:
> 07/04/2014 11:44 PM
>
> To:
> [email protected]
>
>
> On 4-7-2014 21:06, Plamen Dimitrov wrote:
>> >Hi Irmen,
>> >
>> >Thank you for your last reply - it was all I needed to know about customer serialization
>> >and the good practice of relying on the automatic serialization of the proxy objects
>> >themselves.
>> >
>> >I wanted to ask you about another thing - serializing object attributes and possibly
>> >indexing. I have problems serializing cases like
>> >
>> >1) params = Pyro4.Proxy("some-uri-here")
>> >      params["some_present_key"]
>> >
>> >resulting in an error of the kind "TypeError: 'Proxy' object is unsubscriptable".
> Yeah, only method calls are proxied.
> Attribute access and indexing aren't.
>
>
>> >It might be an edge case so I was also wondering about a far simple case when I need to
>> >access a simple attribute/field of a remote object:
>> >
>> >2) firefox = Pyro4.Proxy("PYRONAME:firefox")
>> >      print firefox.download_location
>> >
>> >where the download location is a simple string of the kind
>> >
>> >firefox.download_location = "C:\\"
>> >
>> >I was thinking about relying on a get() method in the first case
>> >(params.get("some_present_key")) and properties in the second. Do you think there is a
>> >more natural solution to this that requires less modification of an already existing code?
> Indeed, the get() method is what I'm suggesting as well.
>
> You could perhaps subclass Pyro4.Proxy with a custom proxy class that implements
> __index__ and make it call your get() method, but I think that's more hassle that it's
> worth.

This is indeed quite much but I prefer to minimize modification of the 
original code. In order for the method above to work I need the get() 
method to exist on the remote object. This is indeed the case here, but 
I was also wondering if I could use similar approach to access remote 
attributes. Is there any way to surpass the Proxy object methods by 
let's say call something of the kind

firefox._original_object.method_that_could_also_be_found_in_the_proxy_class

?

I definitely need access to more than just the remote object's methods 
like its magic methods and attributes even if it is indirectly like 
above. Implementing methods especially for attributes would be a large 
modification of the original code on my side. Do you think this is 
possible? What else could I do?

Kind regards,
Plamen

------------------------------------------------------------------------------
Open source business process management suite built on Java and Eclipse
Turn processes into business applications with Bonita BPM Community Edition
Quickly connect people, data, and systems into organized workflows
Winner of BOSSIE, CODIE, OW2 and Gartner awards
http://p.sf.net/sfu/Bonitasoft

_______________________________________________
Pyro-core mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/pyro-core
smime.p7s (application/pkcs7-signature, 3.9 KB) - not displayed