PageRenderTime 18ms CodeModel.GetById 13ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 0ms

#! | 121 lines | 91 code | 30 blank | 0 comment | 0 complexity | 0ba61ac915224fa0a88addaae8f339a9 MD5 | raw file
  1Filesystem, RCS and CVS client and server classes
  4*** See the security warning at the end of this file! ***
  6This directory contains various modules and classes that support
  7remote file system operations.
  9CVS stuff
 12rcvs			Script to put in your bin directory			Remote CVS client command line interface
 14		CVS admin files classes (used by rrcs)		CVS locking algorithms
 18RCS stuff
 21rrcs			Script to put in your bin directory			Remote RCS client command line interface
 23		Return an RCSProxyClient instance
 25			(has reasonable default server/port/directory)
 26		RCS proxy and server classes (on top of
 28		Local-only RCS base class (affects stdout &
 30			local work files)
 32FSProxy stuff
 34		Old demo for FSProxy		First FSProxy client (used to sync from the Mac)		Filesystem interface classes
 39Generic client/server stuff
 41		Client class		Server class
 44		Security mix-in class (not very secure I think)
 47Other generic stuff
 49		CommandFrameWork class
 51			(used by rcvs, should be used by rrcs as well)
 54Client/Server operation
 57The Client and Server classes implement a simple-minded RPC protocol,
 58using Python's pickle module to transfer arguments, return values and
 59exceptions with the most generality.  The Server class is instantiated
 60with a port number on which it should listen for requests; the Client
 61class is instantiated with a host name and a port number where it
 62should connect to.  Once a client is connected, a TCP connection is
 63maintained between client and server.
 65The Server class currently handles only one connection at a time;
 66however it could be rewritten to allow various modes of operations,
 67using multiple threads or processes or the select() system call as
 68desired to serve multiple clients simultaneously (when using select(),
 69still handling one request at a time).  This would not require
 70rewriting of the Client class.  It may also be possible to adapt the
 71code to use UDP instead of TCP, but then both classes will have to be
 72rewritten (and unless extensive acknowlegements and request serial
 73numbers are used, the server should handle duplicate requests, so its
 74semantics should be idempotent -- shrudder).
 76Even though the FSProxy and RCSProxy modules define client classes,
 77the client class is fully generic -- what methods it supports is
 78determined entirely by the server.  The server class, however, must be
 79derived from.  This is generally done as follows:
 81	from server import Server
 82	from client import Client
 84	# Define a class that performs the operations locally
 85	class MyClassLocal:
 86		def __init__(self): ...
 87		def _close(self): ...
 89	# Derive a server class using multiple inheritance
 90	class MyClassServer(MyClassLocal, Server):
 91		def __init__(self, address):
 92			# Must initialize MyClassLocal as well as Server
 93			MyClassLocal.__init__(self)
 94			Server.__init__(self, address)
 95		def _close(self):
 96			Server._close()
 97			MyClassLocal._close()
 99	# A dummy client class
100	class MyClassClient(Client): pass
102Note that because MyClassLocal isn't used in the definition of
103MyClassClient, it would actually be better to place it in a separate
104module so the definition of MyClassLocal isn't executed when we only
105instantiate a client.
107The modules client and server should probably be renamed to Client and
108Server in order to match the class names.
111*** Security warning: this version requires that you have a file
112$HOME/.python_keyfile at the server and client side containing two
113comma- separated numbers.  The security system at the moment makes no
114guarantees of actuallng being secure -- however it requires that the
115key file exists and contains the same numbers at both ends for this to
116work.  (You can specify an alternative keyfile in $PYTHON_KEYFILE).
117Have a look at the Security class in for details;
118basically, if the key file contains (x, y), then the security server
119class chooses a random number z (the challenge) in the range
12010..100000 and the client must be able to produce pow(z, x, y)
121(i.e. z**x mod y).