def __setattr__(self, name, value): if isproxy(value): if _get_conn(value) is not _get_conn(self): raise TypeError("proxies must belong to the namespace's connection") _get_conn(self).namespace[name] = value else: _get_conn(self).namespace[name] = deliver(value, _get_conn(self))
def dir(*obj): """a version of dir() that supports NetProxies""" if not obj: return sorted(inspect.stack()[1][0].f_locals.keys()) if not len(obj) == 1: raise TypeError("dir expected at most 1 arguments, got %d" % (len(obj),)) obj = obj[0] if orig_isinstance(obj, NetProxy): return _get_conn(obj).modules.__builtin__.dir(obj) else: return orig_dir(obj)
def dir(*obj): """a version of dir() that supports NetProxies""" if not obj: return sorted(inspect.stack()[1][0].f_locals.keys()) if not len(obj) == 1: raise TypeError("dir expected at most 1 arguments, got %d" % (len(obj), )) obj = obj[0] if orig_isinstance(obj, NetProxy): return _get_conn(obj).modules.__builtin__.dir(obj) else: return orig_dir(obj)
def _get_fullname(cls): """ a heuristic to generate a unique identifier for classes, that is not machine-, platform-, or runtime-dependent """ if orig_isinstance(cls, NetProxy): modules = _get_conn(cls).modules.sys.modules else: modules = sys.modules try: filename = modules[cls.__module__].__file__ except (KeyError, AttributeError): filename = cls.__module__ return (filename, cls.__name__)
def reload(module): """a version of reload() that supports NetProxies""" if orig_isinstance(module, NetProxy): return _get_conn(module).modules.__builtin__.reload(module) else: return orig_reload(module)
def getconn(obj): """returns the connection of a NetProxy""" if not isproxy(obj): raise TypeError("`obj` is not a NetProxy") return _get_conn(obj)
def __getattr__(self, name): return _get_conn(self).namespace[name]