[Zodb-checkins] CVS: Zope/lib/python/ZEO - ClientStorage.py:1.76.12.1 ServerStub.py:1.9.14.1 StorageServer.py:1.76.12.2

Andreas Jung andreas@andreas-jung.com
Sat, 16 Nov 2002 11:41:15 -0500


Update of /cvs-repository/Zope/lib/python/ZEO
In directory cvs.zope.org:/tmp/cvs-serv25283/ZEO

Modified Files:
      Tag: ajung-restructuredtext-integration-branch
	ClientStorage.py ServerStub.py StorageServer.py 
Log Message:
merge from trunk

=== Zope/lib/python/ZEO/ClientStorage.py 1.76 => 1.76.12.1 ===
--- Zope/lib/python/ZEO/ClientStorage.py:1.76	Mon Oct  7 17:16:53 2002
+++ Zope/lib/python/ZEO/ClientStorage.py	Sat Nov 16 11:40:44 2002
@@ -398,6 +398,18 @@
         """Storage API: an approximate size of the database, in bytes."""
         return self._info['size']
 
+    def getExtensionMethods(self):
+        """getExtensionMethods
+
+        This returns a dictionary whose keys are names of extra methods
+        provided by this storage. Storage proxies (such as ZEO) should
+        call this method to determine the extra methods that they need
+        to proxy in addition to the standard storage methods.
+        Dictionary values should be None; this will be a handy place
+        for extra marshalling information, should we need it
+        """
+        return self._info['extensionMethods']
+
     def supportsUndo(self):
         """Storage API: return whether we support undo."""
         return self._info['supportsUndo']
@@ -465,6 +477,12 @@
         """
         return self._server.history(oid, version, length)
 
+    def __getattr__(self, name):
+        if self.getExtensionMethods().has_key(name):
+            return self._server.extensionMethod(name)
+        else:
+            raise AttributeError(name)
+
     def loadSerial(self, oid, serial):
         """Storage API: load a historical revision of an object."""
         return self._server.loadSerial(oid, serial)
@@ -792,3 +810,5 @@
     invalidate = invalidateVerify
     end = endVerify
     Invalidate = invalidateTrans
+
+


=== Zope/lib/python/ZEO/ServerStub.py 1.9 => 1.9.14.1 ===
--- Zope/lib/python/ZEO/ServerStub.py:1.9	Tue Oct  1 14:49:12 2002
+++ Zope/lib/python/ZEO/ServerStub.py	Sat Nov 16 11:40:44 2002
@@ -33,6 +33,9 @@
         """
         self.rpc = rpc
 
+    def extensionMethod(self, name):
+        return ExtensionMethodWrapper(self.rpc, name).call
+
     def _update(self):
         """Handle pending incoming messages.
 
@@ -137,3 +140,10 @@
             return self.rpc.call('versions')
         else:
             return self.rpc.call('versions', max)
+
+class ExtensionMethodWrapper:
+    def __init__(self, rpc, name):
+        self.rpc = rpc
+        self.name = name
+    def call(self, *a, **kwa):
+        return apply(self.rpc.call, (self.name,)+a, kwa)


=== Zope/lib/python/ZEO/StorageServer.py 1.76.12.1 => 1.76.12.2 ===
--- Zope/lib/python/ZEO/StorageServer.py:1.76.12.1	Sat Nov  9 03:42:59 2002
+++ Zope/lib/python/ZEO/StorageServer.py	Sat Nov 16 11:40:44 2002
@@ -249,6 +249,18 @@
         self.load = self.storage.load
         self.loadSerial = self.storage.loadSerial
         self.modifiedInVersion = self.storage.modifiedInVersion
+        try:
+            fn = self.storage.getExtensionMethods
+        except AttributeError:
+            # We must be running with a ZODB which
+            # predates adding getExtensionMethods to
+            # BaseStorage. Eventually this try/except
+            # can be removed
+            pass
+        else:
+            for name in fn().keys():
+                if not hasattr(self,name):
+                    setattr(self, name, getattr(self.storage, name))
 
     def check_tid(self, tid, exc=None):
         if self.read_only:
@@ -300,12 +312,21 @@
                 'supportsVersions': self.storage.supportsVersions(),
                 'supportsTransactionalUndo':
                 self.storage.supportsTransactionalUndo(),
+                'extensionMethods': self.getExtensionMethods(),
                 }
 
     def get_size_info(self):
         return {'length': len(self.storage),
                 'size': self.storage.getSize(),
                 }
+
+    def getExtensionMethods(self):
+        try:
+            e = self.storage.getExtensionMethods
+        except AttributeError:
+            return {}
+        else:
+            return e()
 
     def zeoLoad(self, oid):
         v = self.storage.modifiedInVersion(oid)