[pypy-svn] r47095 - pypy/dist/pypy/lib/distributed

fijal at codespeak.net fijal at codespeak.net
Tue Oct 2 12:40:23 CEST 2007


Author: fijal
Date: Tue Oct  2 12:40:22 2007
New Revision: 47095

Modified:
   pypy/dist/pypy/lib/distributed/socklayer.py
   pypy/dist/pypy/lib/distributed/support.py
Log:
unobfusticate support routines


Modified: pypy/dist/pypy/lib/distributed/socklayer.py
==============================================================================
--- pypy/dist/pypy/lib/distributed/socklayer.py	(original)
+++ pypy/dist/pypy/lib/distributed/socklayer.py	Tue Oct  2 12:40:22 2007
@@ -64,9 +64,9 @@
     return SenderWrapper(s).send, ReceiverWrapper(s).receive
 
 def connect(address, socket=socket):
-    from distributed.support import get_remote_view
+    from distributed.support import RemoteView
     from distributed import RemoteProtocol
-    return get_remote_view(RemoteProtocol(*socket_connecter(address, socket)))
+    return RemoteView(RemoteProtocol(*socket_connecter(address, socket)))
 
 def spawn_remote_side(code, gw):
     """ A very simple wrapper around greenexecnet to allow

Modified: pypy/dist/pypy/lib/distributed/support.py
==============================================================================
--- pypy/dist/pypy/lib/distributed/support.py	(original)
+++ pypy/dist/pypy/lib/distributed/support.py	Tue Oct  2 12:40:22 2007
@@ -2,13 +2,16 @@
 """ Some random support functions
 """
 
-def get_remote_view(protocol):
-    # this is dynamic to provide needed level of laziness
-    class RemoteView(object):
-        pass
+from distributed.protocol import ObjectNotFound
 
-    for key in protocol.remote_keys():
-        getter = lambda self: protocol.get_remote(key)
-        setattr(RemoteView, key, property(getter))
+class RemoteView(object):
+    def __init__(self, protocol):
+        self.__dict__['__protocol'] = protocol
 
-    return RemoteView()
+    def __getattr__(self, name):
+        if name == '__dict__':
+            return super(RemoteView, self).__getattr__(name)
+        try:
+            return self.__dict__['__protocol'].get_remote(name)
+        except ObjectNotFound:
+            raise AttributeError(name)


More information about the pypy-svn mailing list