Beispiel #1
0
 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))
Beispiel #2
0
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)
Beispiel #3
0
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)
Beispiel #4
0
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__)
Beispiel #5
0
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__)
Beispiel #6
0
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)
Beispiel #7
0
def getconn(obj):
    """returns the connection of a NetProxy"""
    if not isproxy(obj):
        raise TypeError("`obj` is not a NetProxy")
    return _get_conn(obj)
Beispiel #8
0
 def __getattr__(self, name):
     return _get_conn(self).namespace[name]
Beispiel #9
0
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)