[Zodb-checkins] CVS: ZODB3/ZEO - zeopasswd.py:1.4 version.txt:1.10 monitor.py:1.4 __init__.py:1.20 StorageServer.py:1.100 ServerStub.py:1.17 DebugServer.py:1.2 CommitLog.py:1.6 ClientStorage.py:1.110

Jeremy Hylton jeremy at zope.com
Thu Oct 2 14:17:55 EDT 2003


Update of /cvs-repository/ZODB3/ZEO
In directory cvs.zope.org:/tmp/cvs-serv18770/ZEO

Modified Files:
	zeopasswd.py version.txt monitor.py __init__.py 
	StorageServer.py ServerStub.py DebugServer.py CommitLog.py 
	ClientStorage.py 
Log Message:
Merge changes from Zope-2_7-branch to the trunk.


=== ZODB3/ZEO/zeopasswd.py 1.3 => 1.4 ===
--- ZODB3/ZEO/zeopasswd.py:1.3	Wed Jul 30 16:39:54 2003
+++ ZODB3/ZEO/zeopasswd.py	Thu Oct  2 14:17:22 2003
@@ -17,16 +17,12 @@
 usage: python zeopasswd.py [options] username [password]
 
 -C/--configuration URL -- configuration file or URL
--p/--protocol -- authentication protocol name
--f/--filename -- authentication database filename
--r/--realm -- authentication database realm
 -d/--delete -- delete user instead of updating password
 """
 
 import getopt
 import getpass
 import sys
-import os
 
 import ZConfig
 import ZEO
@@ -39,41 +35,22 @@
 def options(args):
     """Password-specific options loaded from regular ZEO config file."""
 
+    schema = ZConfig.loadSchema(os.path.join(os.path.dirname(ZEO.__file__),
+                                             "schema.xml"))
+
     try:
-        options, args = getopt.getopt(args, "dr:p:f:C:", ["configure=", 
-                                                          "protocol=", 
-                                                          "filename=",
-                                                          "realm"])
+        options, args = getopt.getopt(args, "C:", ["configure="])
     except getopt.error, msg:
         usage(msg)
     config = None
-    delete = 0
-    auth_protocol = None
-    auth_db = "" 
-    auth_realm = None
+    delete = False
     for k, v in options:
         if k == '-C' or k == '--configure':
-            schemafile = os.path.join(os.path.dirname(ZEO.__file__),
-                                                     "schema.xml")
-            schema = ZConfig.loadSchema(schemafile)
             config, nil = ZConfig.loadConfig(schema, v)
         if k == '-d' or k == '--delete':
-            delete = 1
-        if k == '-p' or k == '--protocol':
-            auth_protocol = v
-        if k == '-f' or k == '--filename':
-            auth_db = v
-        if k == '-r' or k == '--realm':
-            auth_realm = v
-
-    if config is not None:
-        if auth_protocol or auth_db:
-            usage("Conflicting options; use either -C *or* -p and -f")
-        auth_protocol = config.zeo.authentication_protocol
-        auth_db = config.zeo.authentication_database
-        auth_realm = config.zeo.authentication_realm
-    elif not (auth_protocol and auth_db):
-        usage("Must specifiy configuration file or protocol and database")
+            delete = True
+    if config is None:
+        usage("Must specifiy configuration file")
 
     password = None
     if delete:
@@ -91,22 +68,21 @@
             username = args[0]
         else:
             username, password = args
-        
-    return auth_protocol, auth_db, auth_realm, delete, username, password
+
+    return config.zeo, delete, username, password
 
 def main(args=None):
-    p, auth_db, auth_realm, delete, username, password = options(args)
+    options, delete, username, password = options(args)
+    p = options.authentication_protocol
     if p is None:
         usage("ZEO configuration does not specify authentication-protocol")
     if p == "digest":
         from ZEO.auth.auth_digest import DigestDatabase as Database
     elif p == "srp":
         from ZEO.auth.auth_srp import SRPDatabase as Database
-    else:
-        raise ValueError, "Unknown database type %r" % p
-    if auth_db is None:
+    if options.authentication_database is None:
         usage("ZEO configuration does not specify authentication-database")
-    db = Database(auth_db, auth_realm)
+    db = Database(options.authentication_database)
     if delete:
         db.del_user(username)
     else:
@@ -116,5 +92,4 @@
     db.save()
 
 if __name__ == "__main__":
-    main(sys.argv[1:])
-
+    main(sys.argv)


=== ZODB3/ZEO/version.txt 1.9 => 1.10 ===
--- ZODB3/ZEO/version.txt:1.9	Mon Jun 16 17:49:58 2003
+++ ZODB3/ZEO/version.txt	Thu Oct  2 14:17:22 2003
@@ -1,5 +1 @@
-2.1b2
-
-
-
-
+2.2c1


=== ZODB3/ZEO/monitor.py 1.3 => 1.4 ===
--- ZODB3/ZEO/monitor.py:1.3	Wed Jan 15 16:23:16 2003
+++ ZODB3/ZEO/monitor.py	Thu Oct  2 14:17:22 2003
@@ -54,7 +54,7 @@
             elif field == "Active transactions":
                 self.active_txns = int(value)
             elif field == "Commit lock held for":
-                # This assumes 
+                # This assumes
                 self.lock_time = time.time() - int(value)
             elif field == "Commits":
                 self.commits = int(value)
@@ -112,7 +112,7 @@
         n = self.socket.send(s)
         if n < len(s):
             self.buf.append(s[:n])
-            
+
         if self.closed and not self.buf:
             asyncore.dispatcher.close(self)
 


=== ZODB3/ZEO/__init__.py 1.19 => 1.20 ===
--- ZODB3/ZEO/__init__.py:1.19	Mon Jun 16 17:49:58 2003
+++ ZODB3/ZEO/__init__.py	Thu Oct  2 14:17:22 2003
@@ -15,10 +15,10 @@
 
 See the file README.txt in this directory for an overview.
 
-ZEO is now part of ZODB; ZODB's home on the web is 
+ZEO is now part of ZODB; ZODB's home on the web is
 
     http://www.zope.org/Wikis/ZODB
 
 """
 
-version = "2.1b2"
+version = "2.2c1"


=== ZODB3/ZEO/StorageServer.py 1.99 => 1.100 ===
--- ZODB3/ZEO/StorageServer.py:1.99	Mon Sep 15 12:29:19 2003
+++ ZODB3/ZEO/StorageServer.py	Thu Oct  2 14:17:22 2003
@@ -43,7 +43,7 @@
 from ZODB.POSException import TransactionError, ReadOnlyError, ConflictError
 from ZODB.referencesf import referencesf
 from ZODB.Transaction import Transaction
-from ZODB.utils import u64
+from ZODB.utils import u64, oid_repr
 
 _label = "ZSS" # Default label used for logging.
 
@@ -90,7 +90,7 @@
         self._extensions = {}
         for func in self.extensions:
             self._extensions[func.func_name] = None
-        
+
     def finish_auth(self, authenticated):
         if not self.auth_realm:
             return 1
@@ -99,7 +99,7 @@
 
     def set_database(self, database):
         self.database = database
-        
+
     def notifyConnected(self, conn):
         self.connection = conn # For restart_other() below
         self.client = self.ClientStorageStubClass(conn)
@@ -189,7 +189,7 @@
         if not protocol or protocol == 'none':
             return None
         return protocol
-    
+
     def register(self, storage_id, read_only):
         """Select the storage that this client will use
 
@@ -398,6 +398,7 @@
     def _clear_transaction(self):
         # Common code at end of tpc_finish() and tpc_abort()
         self.transaction = None
+        self.txnlog.close()
         if self.locked:
             self.locked = 0
             self.timeout.end(self)
@@ -483,6 +484,8 @@
             self.store_failed = 1
             if isinstance(err, ConflictError):
                 self.stats.conflicts += 1
+                self.log("conflict error oid=%s msg=%s" %
+                         (oid_repr(oid), str(err)), zLOG.BLATHER)
             if not isinstance(err, TransactionError):
                 # Unexpected errors are logged and passed to the client
                 exc_info = sys.exc_info()
@@ -506,6 +509,7 @@
                 self.invalidated.append((oid, version))
         if newserial == ResolvedSerial:
             self.stats.conflicts_resolved += 1
+            self.log("conflict resolved oid=%s" % oid_repr(oid), zLOG.BLATHER)
         self.serials.append((oid, newserial))
         return err is None
 
@@ -680,7 +684,7 @@
             It should be in a format compatible with the authentication
             protocol used; for instance, "sha" and "srp" require different
             formats.
-            
+
             Note that to implement an authentication protocol, a server
             and client authentication mechanism must be implemented in a
             auth_* module, which should be stored inside the "auth"
@@ -728,7 +732,7 @@
             self.monitor = StatsServer(monitor_address, self.stats)
         else:
             self.monitor = None
-            
+
     def _setup_auth(self, protocol):
         # Can't be done in global scope, because of cyclic references
         from ZEO.auth import get_module
@@ -739,9 +743,9 @@
         if not module:
             log("%s: no such an auth protocol: %s" % (name, protocol))
             return
-        
+
         storage_class, client, db_class = module
-        
+
         if not storage_class or not issubclass(storage_class, ZEOStorage):
             log(("%s: %s isn't a valid protocol, must have a StorageClass" %
                  (name, protocol)))
@@ -750,7 +754,7 @@
         self.ZEOStorageClass = storage_class
 
         log("%s: using auth protocol: %s" % (name, protocol))
-        
+
         # We create a Database instance here for use with the authenticator
         # modules. Having one instance allows it to be shared between multiple
         # storages, avoiding the need to bloat each with a new authenticator
@@ -762,7 +766,7 @@
                              "does not match storage realm %r"
                              % (self.database.realm, self.auth_realm))
 
-        
+
     def new_connection(self, sock, addr):
         """Internal: factory to create a new connection.
 
@@ -776,7 +780,7 @@
             zstorage.set_database(self.database)
         else:
             zstorage = self.ZEOStorageClass(self, self.read_only)
-            
+
         c = self.ManagedServerConnectionClass(sock, addr, zstorage, self)
         log("new connection %s: %s" % (addr, `c`))
         return c
@@ -846,12 +850,12 @@
         if not self.invq:
             log("invq empty")
             return None, []
-        
+
         earliest_tid = self.invq[0][0]
         if earliest_tid > tid:
             log("tid to old for invq %s < %s" % (u64(tid), u64(earliest_tid)))
             return None, []
-        
+
         oids = {}
         for tid, L in self.invq:
             for key in L:
@@ -928,6 +932,7 @@
         self._cond.acquire()
         try:
             assert self._client is not None
+            assert self._client is client
             self._client = None
             self._deadline = None
         finally:
@@ -953,7 +958,6 @@
                 self._trigger.pull_trigger(lambda: client.connection.close())
             else:
                 time.sleep(howlong)
-        self.trigger.close()
 
 def run_in_thread(method, *args):
     t = SlowMethodThread(method, args)


=== ZODB3/ZEO/ServerStub.py 1.16 => 1.17 ===
--- ZODB3/ZEO/ServerStub.py:1.16	Fri May 30 15:20:57 2003
+++ ZODB3/ZEO/ServerStub.py	Thu Oct  2 14:17:22 2003
@@ -32,9 +32,13 @@
         zrpc.connection.Connection class.
         """
         self.rpc = rpc
-        if self.rpc.peer_protocol_version == 'Z200':
+        # Wait until we know what version the other side is using.
+        while rpc.peer_protocol_version is None:
+            rpc.pending()
+        if rpc.peer_protocol_version == 'Z200':
             self.lastTransaction = lambda: None
             self.getInvalidations = lambda tid: None
+            self.getAuthProtocol = lambda: None
 
     def extensionMethod(self, name):
         return ExtensionMethodWrapper(self.rpc, name).call
@@ -47,7 +51,7 @@
 
     def getAuthProtocol(self):
         return self.rpc.call('getAuthProtocol')
-    
+
     def lastTransaction(self):
         # Not in protocol version 2.0.0; see __init__()
         return self.rpc.call('lastTransaction')
@@ -150,6 +154,6 @@
     def __init__(self, rpc, name):
         self.rpc = rpc
         self.name = name
-        
+
     def call(self, *a, **kwa):
         return self.rpc.call(self.name, *a, **kwa)


=== ZODB3/ZEO/DebugServer.py 1.1 => 1.2 ===
--- ZODB3/ZEO/DebugServer.py:1.1	Wed Jan 15 16:26:53 2003
+++ ZODB3/ZEO/DebugServer.py	Thu Oct  2 14:17:22 2003
@@ -28,7 +28,7 @@
 ERROR = 4
 
 class DebugManagedServerConnection(ManagedServerConnection):
-    
+
     def __init__(self, sock, addr, obj, mgr):
         # mgr is the DebugServer instance
         self.mgr = mgr
@@ -67,7 +67,7 @@
 
     ZEOStorageClass = DebugZEOStorage
     ManagedServerConnectionClass = DebugManagerConnection
-    
+
     def __init__(self, *args, **kwargs):
         StorageServer.__init__(*args, **kwargs)
         self._setup_record(kwargs["record"])


=== ZODB3/ZEO/CommitLog.py 1.5 => 1.6 ===
--- ZODB3/ZEO/CommitLog.py:1.5	Mon Sep 15 12:29:19 2003
+++ ZODB3/ZEO/CommitLog.py	Thu Oct  2 14:17:22 2003
@@ -42,3 +42,8 @@
         self.read = 1
         self.file.seek(0)
         return self.stores, cPickle.Unpickler(self.file)
+
+    def close(self):
+        if self.file:
+            self.file.close()
+            self.file = None


=== ZODB3/ZEO/ClientStorage.py 1.109 => 1.110 ===
--- ZODB3/ZEO/ClientStorage.py:1.109	Mon Sep 15 12:29:19 2003
+++ ZODB3/ZEO/ClientStorage.py	Thu Oct  2 14:17:22 2003
@@ -99,7 +99,7 @@
                  name='', client=None, debug=0, var=None,
                  min_disconnect_poll=5, max_disconnect_poll=300,
                  wait_for_server_on_startup=None, # deprecated alias for wait
-                 wait=None, # defaults to 1
+                 wait=None, wait_timeout=None,
                  read_only=0, read_only_fallback=0,
                  username='', password='', realm=None):
         """ClientStorage constructor.
@@ -152,6 +152,9 @@
         wait -- A flag indicating whether to wait until a connection
             with a server is made, defaulting to true.
 
+        wait_timeout -- Maximum time to wait for a connection before
+            giving up.  Only meaningful if wait is True.
+
         read_only -- A flag indicating whether this should be a
             read-only storage, defaulting to false (i.e. writing is
             allowed by default).
@@ -302,7 +305,7 @@
                                                     tmax=max_disconnect_poll)
 
         if wait:
-            self._wait()
+            self._wait(wait_timeout)
         else:
             # attempt_connect() will make an attempt that doesn't block
             # "too long," for a very vague notion of too long.  If that
@@ -313,7 +316,9 @@
             if not self._ready.isSet():
                 self._cache.open()
 
-    def _wait(self):
+    def _wait(self, timeout=None):
+        if timeout is not None:
+            deadline = time.time() + timeout
         # Wait for a connection to be established.
         self._rpc_mgr.connect(sync=1)
         # When a synchronous connect() call returns, there is
@@ -326,6 +331,9 @@
                 self._ready.wait(30)
                 if self._ready.isSet():
                     break
+                if timeout and time.time() > deadline:
+                    log2(PROBLEM, "Timed out waiting for connection")
+                    break
                 log2(INFO, "Waiting for cache verification to finish")
         else:
             self._wait_sync()
@@ -434,8 +442,10 @@
         auth = stub.getAuthProtocol()
         log2(INFO, "Server authentication protocol %r" % auth)
         if auth:
-            if self.doAuth(auth, stub):
+            skey = self.doAuth(auth, stub)
+            if skey:
                 log2(INFO, "Client authentication successful")
+                conn.setSessionKey(skey)
             else:
                 log2(ERROR, "Authentication failed")
                 raise AuthError, "Authentication failed"




More information about the Zodb-checkins mailing list