[Zodb-checkins] SVN: ZODB/trunk/src/ZODB/Connection.py Use issubclass rather than interface introspection to decide if an

Jim Fulton jim at zope.com
Wed Jun 6 12:14:23 EDT 2007


Log message for revision 76434:
  Use issubclass rather than interface introspection to decide if an
  object is a blob.  YAGNI support for multiple blob implementations --
  at least for now.
  

Changed:
  U   ZODB/trunk/src/ZODB/Connection.py

-=-
Modified: ZODB/trunk/src/ZODB/Connection.py
===================================================================
--- ZODB/trunk/src/ZODB/Connection.py	2007-06-06 15:54:34 UTC (rev 76433)
+++ ZODB/trunk/src/ZODB/Connection.py	2007-06-06 16:14:22 UTC (rev 76434)
@@ -29,7 +29,8 @@
 # interfaces
 from persistent.interfaces import IPersistentDataManager
 from ZODB.interfaces import IConnection
-from ZODB.interfaces import IBlob, IBlobStorage
+from ZODB.interfaces import IBlobStorage
+from ZODB.blob import Blob
 from transaction.interfaces import ISavepointDataManager
 from transaction.interfaces import IDataManagerSavepoint
 from transaction.interfaces import ISynchronizer
@@ -607,13 +608,7 @@
                 self._modified.append(oid)
             p = writer.serialize(obj)  # This calls __getstate__ of obj
 
-            # This is a workaround to calling IBlob.proivdedBy(obj). Calling
-            # Interface.providedBy on a object to be stored can invertible
-            # set the '__providedBy__' and '__implemented__' attributes on the
-            # object. This interferes the storing of the object by requesting
-            # that the values of these objects should be stored with the ZODB.
-            providedBy = getattr(obj, '__providedBy__', None)
-            if providedBy is not None and IBlob in providedBy:
+            if isinstance(obj, Blob):
                 if not IBlobStorage.providedBy(self._storage):
                     raise Unsupported(
                         "Storing Blobs in %s is not supported." % 
@@ -862,10 +857,9 @@
         obj._p_serial = serial
 
         # Blob support
-        providedBy = getattr(obj, '__providedBy__', None)
-        if providedBy is not None and IBlob in providedBy:
+        if isinstance(obj, Blob):
             obj._p_blob_uncommitted = None
-            obj._p_blob_data = self._storage.loadBlob(obj._p_oid, serial)
+            obj._p_blob_committed = self._storage.loadBlob(obj._p_oid, serial)
 
     def _load_before_or_conflict(self, obj):
         """Load non-current state for obj or raise ReadConflictError."""



More information about the Zodb-checkins mailing list