def _box(self, obj): # Might be nice to have *obj """label and store a local object in such a way that it can be sent and unboxed the remote party either by-value or by-reference returns package package = (label, contents) :for some labels, contents may be a tuple """ if brine.dumpable(obj): # Immutable obj supported by brine label = global_consts.LABEL_IMMUTABLE contents = obj package = (label, contents) elif type(obj) is tuple: # Tuple containing mutables label = global_consts.LABEL_MUT_TUPLE contents = tuple(self._box(item) for item in obj) package = (label, contents) elif netref.is_netref(obj) and obj.____conn__() is self: # This one detects local proxy objects label = global_consts.LABEL_LOCAL_OBJECT_REF contents = obj.____oid__ package = (label, contents) print("using the third way in _box, detected local proxy object, wow, how did this come to be") # Will have to see this one in action else: # Pure mutable data oid = id(obj) cls = getattr(obj, "__class__", type(obj)) #Add object to local object dict, I would have thought this should be a weakkeydict self._local_objects[oid] = obj # the same id could be used later if garbage collected label = global_consts.LABEL_NETREFABLE contents = (oid, cls.__name__, cls.__module__) package = (label, contents) # cls.inspect.getmodule.__name__ !!!!!!!!!!!!!Maybe better !!!!!!!!!!!!!!!!!!!!!!! # If can't get name or module what to do???!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! return package
def make_dumpable(obj): if brine.dumpable(obj): return obj else: return repr(obj)