Commit 698c1011 authored by Jim Fulton's avatar Jim Fulton

We want interfaces provided by the client storage to reflect

interfaces provided by the served storage on the storage server.

The old way this was done was to copy all of the interface
declarations from the served storage. This has 2 problems:

1. Not all interfaces copied were actually provided by the client
storage. Just because a remote storage provides an interface, doesn't
mean the client storage can, especially if the method (or attribute)
isn't supported by the ZEO protocol.

2. Older clients could get import errors while trying to import copies
interfaces.

Now, we only declare from a known set of interfaces defined on the client.
parent 31f05781
......@@ -559,14 +559,15 @@ class ClientStorage(object):
self._handle_extensions()
# Decorate ClientStorage with all interfaces that the backend storage
# supports.
remote_interfaces = []
for module_name, interface_name in self._info['interfaces']:
module = __import__(module_name, globals(), locals(), [interface_name])
interface = getattr(module, interface_name)
remote_interfaces.append(interface)
zope.interface.directlyProvides(self, remote_interfaces)
for iface in (
ZODB.interfaces.IStorageRestoreable,
ZODB.interfaces.IStorageIteration,
ZODB.interfaces.IStorageUndoable,
ZODB.interfaces.IStorageCurrentRecordIteration,
ZODB.interfaces.IBlobStorage,
):
if (iface.__module__, iface.__name__) in self._info.get('interfaces', ()):
zope.interface.alsoProvides(self, iface)
def _handle_extensions(self):
for name in self.getExtensionMethods().keys():
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment