示例#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))
示例#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)
示例#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)
示例#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__)
示例#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__)
示例#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)
示例#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)
示例#8
0
 def __getattr__(self, name):
     return _get_conn(self).namespace[name]
示例#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)