Migrating an object through Pyro

I use Pyro in a project and cannot figure out how to transfer a complete object by wire. The object is not distributed (my distributed objects work fine), but should function as an argument to an already accessible distributed object.

My object is derived from a custom class containing some methods, and some variables are an integer and a list. The class is available for both the server and the client. When using my object as an argument to the distributed object method, the whole variable is "accepted" correctly, but the list is empty, although I see that it contains values โ€‹โ€‹immediately before it is "sent".

Why is this?

Short version of the class:

class Collection(Pyro.core.ObjBase): num = 0 operations = [("Operation:", "Value:", "Description", "Timestamp")] def __init__(self): Pyro.core.ObjBase.__init__(self) def add(self, val, desc): entry = ("Add", val, desc, strftime("%Y-%m-%d %H:%M:%S")) self.operations.append(entry) self.num = self.num + 1 def printop(self): print "This collection will execute the following operations:" for item in self.operations: print item 

Distributed Object Receive Method:

 def apply(self, collection): print "Todo: Apply collection" #op = collection.getop() print "Number of collected operations:", collection.a collection.printop() 
+4
source share
2 answers

Operations are an attribute of a class, not an attribute of an object. That is why it is not tolerated. Try setting it to __init__ through self.operations = <whatever> .

+4
source

Your apply reception method has the same name as the Python built-in function.

+1
source

All Articles