[Zodb-checkins] CVS: Packages/ZEO - ClientStorage.py:1.77 ServerStub.py:1.10 StorageServer.py:1.78
Toby Dickenson
tdickenson@geminidataloggers.com
Wed, 13 Nov 2002 06:24:36 -0500
Update of /cvs-repository/Packages/ZEO
In directory cvs.zope.org:/tmp/cvs-serv17817
Modified Files:
ClientStorage.py ServerStub.py StorageServer.py
Log Message:
Merged toby-extension-method-branch - ZEO now asks its storages if there are extra methods that should be proxied by the ClientStorage. This is useful for storages which have features not covered by the standard storage API
=== Packages/ZEO/ClientStorage.py 1.76 => 1.77 ===
--- Packages/ZEO/ClientStorage.py:1.76 Mon Oct 7 17:16:53 2002
+++ Packages/ZEO/ClientStorage.py Wed Nov 13 06:24:36 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
+
+
=== Packages/ZEO/ServerStub.py 1.9 => 1.10 ===
--- Packages/ZEO/ServerStub.py:1.9 Tue Oct 1 14:49:12 2002
+++ Packages/ZEO/ServerStub.py Wed Nov 13 06:24:36 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)
=== Packages/ZEO/StorageServer.py 1.77 => 1.78 ===
--- Packages/ZEO/StorageServer.py:1.77 Wed Oct 30 16:20:00 2002
+++ Packages/ZEO/StorageServer.py Wed Nov 13 06:24:36 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)