Re: Serialization of return value (2)
Borek Patzak <[email protected]> Fri, 07 Nov 2014 08:48:48 +0100
| Newsgroups | gmane.comp.python.pyro |
|---|---|
| Message-ID | <[email protected]> |
>> >Hello, >> >I have encountered a strange problem with return value from remote >> >class, when using pickle protocol. >> >When type of return value is a class, then depending whether it is >> >derived from object base or not, the return value is different. >> >When I run a client, the following response is received: >> >$ python client.py >> >Uri:PYRO:obj_58a48bb0def74534b8749c6b10d3fa8b-savSHZN5Fh8qMp+WYRx65w@public.gmane.org:9091 >> >Server: <Pyro4.core.Proxy at 0x7f1592605510, not connected, for >> >PYRO:obj_58a48bb0def74534b8749c6b10d3fa8b-savSHZN5Fh8qMp+WYRx65w@public.gmane.org:9091> >> >a:PYRO:obj_140031e8eb8f4eaf881a2922b49738c5-savSHZN5Fh8qMp+WYRx65w@public.gmane.org:9091 >> >b: <Pyro4.core.Proxy at 0x7f1592605610, not connected, for >> >PYRO:obj_140031e8eb8f4eaf881a2922b49738c5-savSHZN5Fh8qMp+WYRx65w@public.gmane.org:9091> >> >finished >> > > > >> >1) is this intended behaviour? > Yes, this is Pyro's autoproxying behavior which is turned on by default. > Seehttps://pythonhosted.org/Pyro4/servercode.html#autoproxying > >> >2) for classes derived from object base, can the the type of return >> >value (local copy instead of URI) changed? > Yes, disable the autoproxy setting. > > Anyway you should not use old-style classes really. Pyro4 won't support them. I guess > I'll have to add a check in the daemon that prevents registering old-style class instances. > > > Irmen Hi Irmen, thank you for your answer. I have two follow up questions: 1) From the docs I understood that autoproxy feature affects how pyro objects are passed (https://pythonhosted.org/Pyro4/servercode.html#autoproxying). In the example I have provided at the beginning this post thread, the class attribute has not been registered, so its not a pyro objects. It is being returned and the return value (copy or proxy) is affected by autoproxy setting. Does this mean that if class is registered then all attributes are registered as well? 2) In my speficif case, the autoproxy ON is ok, but in some specific cases I would like to receive a copy instead of proxy object. Could be autoproxy behaviour altered for specific call or what is the suggested way to get a copy? Thanks, Borek ------------------------------------------------------------------------------