Re: Are decorators supported?
Richard van Bemmelen <[email protected]> Fri, 14 Feb 2014 21:06:19 +0100
| Newsgroups | gmane.comp.python.pyro |
|---|---|
| Message-ID | <CAMEWXj05PeH-NP30Cr6pXTdpxaEcvPBE5XjQostUFivXgV-qJQ@mail.gmail.com> |
Thanks for your explanation, Éric regards, Richard 2014-02-12 16:06 GMT+01:00 Éric Piel <[email protected]>: > On 11/02/14 22:25, Richard van Bemmelen wrote: > > I am trying to add a function to an instance of a Pyro4 object, like so: > > > > > > > > def addto(instance): > > def decorator(f): > > import types > > f = types.MethodType(f, instance, instance.__class__) > > setattr(instance, f.func_name, f) > > return f > > return decorator > > > > cs = Pyro4.Proxy("PYRONAME:example.cserv") > > > > @addto(cs) > > def getInit(self): > > print self.initCsd > > return self.initCsd > > > > > > print getInit() > > > > This code is running in a client. > > It should print the content of self.initCsd on the server and on the > client. > > Instead, I get this on the client (nothing on the server): > > > > <Pyro4.core._RemoteMethod object at 0x105523dd0> > > <Pyro4.core._RemoteMethod object at 0x105523dd0> > > > > So, is this supported? > Hi, > What you are doing is not supported. It's not related to decorators > though. What Pyro doesn't support is 1) adding an attribute to an object > remotely accessed (i.e., a Proxy), and 2) remote content access. In your > code, what happens is that the method is correctly added to the proxy, > and then the call displays .initCsd, which is a RemoteMethod, like > everything on a Proxy. > > If you were doing the addto() on the server side, it would then work: > both the client and the server sides would see the new method, and the > execution would happen on the server so it would be able to access > .initCsd . I doubt there is any nice way to do what you want (adding > code to a remote object). > > Best, > Éric > > > > ------------------------------------------------------------------------------ > Android apps run on BlackBerry 10 > Introducing the new BlackBerry 10.2.1 Runtime for Android apps. > Now with support for Jelly Bean, Bluetooth, Mapview and more. > Get your Android app in front of a whole new audience. Start now. > > http://pubads.g.doubleclick.net/gampad/clk?id=124407151&iu=/4140/ostg.clktrk > _______________________________________________ > Pyro-core mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/pyro-core > ------------------------------------------------------------------------------ Android apps run on BlackBerry 10 Introducing the new BlackBerry 10.2.1 Runtime for Android apps. Now with support for Jelly Bean, Bluetooth, Mapview and more. Get your Android app in front of a whole new audience. Start now. http://pubads.g.doubleclick.net/gampad/clk?id=124407151&iu=/4140/ostg.clktrk _______________________________________________ Pyro-core mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/pyro-core