diff -ur rpyc-3.0.7/rpyc/core/netref.py rpyc-local/rpyc/core/netref.py --- rpyc-3.0.7/rpyc/core/netref.py 2009-09-22 13:38:29.000000000 +0200 +++ rpyc-local/rpyc/core/netref.py 2009-11-29 17:39:55.000000000 +0100 @@ -14,7 +14,7 @@ _local_netref_attrs = frozenset([ '____conn__', '____oid__', '__class__', '__cmp__', '__del__', '__delattr__', '__dir__', '__doc__', '__getattr__', '__getattribute__', '__hash__', - '__init__', '__metaclass__', '__module__', '__new__', '__reduce__', + '__metaclass__', '__module__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__slots__', '__str__', '__weakref__', '__dict__', '__members__', '__methods__', ]) @@ -64,7 +64,7 @@ """the base netref object, from which all netref classes derive""" __metaclass__ = NetrefMetaclass __slots__ = ["____conn__", "____oid__", "__weakref__"] - def __init__(self, conn, oid): + def _netref_init__(self, conn, oid): self.____conn__ = conn self.____oid__ = oid def __del__(self): diff -ur rpyc-3.0.7/rpyc/core/protocol.py rpyc-local/rpyc/core/protocol.py --- rpyc-3.0.7/rpyc/core/protocol.py 2009-09-22 13:38:29.000000000 +0200 +++ rpyc-local/rpyc/core/protocol.py 2009-11-29 17:39:39.000000000 +0100 @@ -50,6 +50,7 @@ allow_pickle = False, connid = None, credentials = None, + call_by_value_for_builtin_mutable_types=True, ) _connection_id_generator = itertools.count(1) @@ -180,7 +181,15 @@ self._local_objects.add(obj) cls = getattr(obj, "__class__", type(obj)) return consts.LABEL_REMOTE_REF, (id(obj), cls.__name__, cls.__module__) - + + def _valuefy(self, obj): + if self._config["call_by_value_for_builtin_mutable_types"]: + if isinstance(obj, list): + return list(obj) + elif isinstance(obj, dict): + return dict(obj) + return obj + def _unbox(self, package): """recreate a local object representation of the remote object: if the object is passed by value, just return it; if the object is passed by @@ -211,8 +220,10 @@ info = self.sync_request(consts.HANDLE_INSPECT, oid) cls = netref.class_factory(clsname, modname, info) self._netref_classes_cache[typeinfo] = cls - return cls(weakref.ref(self), oid) - + inst = object.__new__(cls) + netref.BaseNetref._netref_init__(inst, weakref.ref(self), oid) + return inst + # # dispatching # @@ -423,7 +434,17 @@ def _handle_hash(self, oid): return hash(self._local_objects[oid]) def _handle_call(self, oid, args, kwargs): - return self._local_objects[oid](*args, **dict(kwargs)) + r = repr(self._local_objects[oid]) + if "Type" in r: # XXX make more distinct or check whether needed for all types + meths = args[2] + for meth in meths: # build wrappers around netref funcs for qt + def make_wrapper(meth): + return lambda *a, **kw: meth(*a, **kw) + methfunc = meths[meth] + if callable(methfunc): + meths[meth] = make_wrapper(methfunc) + return self._local_objects[oid](*[self._valuefy(arg) for arg in args], + **dict(kwargs)) def _handle_dir(self, oid): return tuple(dir(self._local_objects[oid])) def _handle_inspect(self, oid):