Back to index

python3.2  3.2.2
Classes | Functions | Variables
idlelib.rpc Namespace Reference

Classes

class  RPCServer
class  SocketIO
class  RemoteObject
class  RemoteProxy
class  RPCHandler
class  RPCClient
class  RPCProxy
class  MethodProxy

Functions

def unpickle_code
def pickle_code
def remoteref
def _getmethods
def _getattributes

Variables

int BUFSIZE = 8
string LOCALHOST = '127.0.0.1'
dictionary objecttable = {}
tuple request_queue = queue.Queue(0)
tuple response_queue = queue.Queue(0)

Detailed Description

RPC Implemention, originally written for the Python Idle IDE

For security reasons, GvR requested that Idle's Python execution server process
connect to the Idle process, which listens for the connection.  Since Idle has
has only one client per server, this was not a limitation.

   +---------------------------------+ +-------------+
   | socketserver.BaseRequestHandler | | SocketIO    |
   +---------------------------------+ +-------------+
           ^                   | register()  |
           |                   | unregister()|
           |                   +-------------+
           |                      ^  ^
           |                      |  |
           | + -------------------+  |
           | |                       |
   +-------------------------+        +-----------------+
   | RPCHandler              |        | RPCClient       |
   | [attribute of RPCServer]|        |                 |
   +-------------------------+        +-----------------+

The RPCServer handler class is expected to provide register/unregister methods.
RPCHandler inherits the mix-in class SocketIO, which provides these methods.

See the Idle run.main() docstring for further information on how this was
accomplished in Idle.

Function Documentation

def idlelib.rpc._getattributes (   obj,
  attributes 
) [private]

Definition at line 579 of file rpc.py.

00579 
00580 def _getattributes(obj, attributes):
00581     for name in dir(obj):
00582         attr = getattr(obj, name)
00583         if not hasattr(attr, '__call__'):
00584             attributes[name] = 1

Here is the call graph for this function:

Here is the caller graph for this function:

def idlelib.rpc._getmethods (   obj,
  methods 
) [private]

Definition at line 568 of file rpc.py.

00568 
00569 def _getmethods(obj, methods):
00570     # Helper to get a list of methods from an object
00571     # Adds names to dictionary argument 'methods'
00572     for name in dir(obj):
00573         attr = getattr(obj, name)
00574         if hasattr(attr, '__call__'):
00575             methods[name] = 1
00576     if isinstance(obj, type):
00577         for super in obj.__bases__:
00578             _getmethods(super, methods)

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 50 of file rpc.py.

00050 
00051 def pickle_code(co):
00052     assert isinstance(co, types.CodeType)
00053     ms = marshal.dumps(co)
00054     return unpickle_code, (ms,)
00055 
00056 # XXX KBK 24Aug02 function pickling capability not used in Idle
00057 #  def unpickle_function(ms):
00058 #      return ms
00059 
00060 #  def pickle_function(fn):
00061 #      assert isinstance(fn, type.FunctionType)
00062 #      return repr(fn)
00063 
00064 copyreg.pickle(types.CodeType, pickle_code, unpickle_code)
00065 # copyreg.pickle(types.FunctionType, pickle_function, unpickle_function)

Here is the call graph for this function:

def idlelib.rpc.remoteref (   obj)

Definition at line 485 of file rpc.py.

00485 
00486 def remoteref(obj):
00487     oid = id(obj)
00488     objecttable[oid] = obj
00489     return RemoteProxy(oid)

Here is the caller graph for this function:

Definition at line 45 of file rpc.py.

00045 
00046 def unpickle_code(ms):
00047     co = marshal.loads(ms)
00048     assert isinstance(co, types.CodeType)
00049     return co


Variable Documentation

Definition at line 66 of file rpc.py.

Definition at line 67 of file rpc.py.

Definition at line 119 of file rpc.py.

Definition at line 120 of file rpc.py.

Definition at line 121 of file rpc.py.