[Zope-CVS] CVS: Products/Ape/lib/apelib/core - events.py:1.4.4.2 gateways.py:1.6.2.1 interfaces.py:1.7.4.2 io.py:1.4.2.2

Shane Hathaway shane@zope.com
Thu, 24 Jul 2003 08:16:06 -0400


Update of /cvs-repository/Products/Ape/lib/apelib/core
In directory cvs.zope.org:/tmp/cvs-serv8851/lib/apelib/core

Modified Files:
      Tag: ape-scan-branch
	events.py gateways.py interfaces.py io.py 
Log Message:
Modified strategy that asks gateways for sources directly.


=== Products/Ape/lib/apelib/core/events.py 1.4.4.1 => 1.4.4.2 ===
--- Products/Ape/lib/apelib/core/events.py:1.4.4.1	Wed Jul 23 00:12:41 2003
+++ Products/Ape/lib/apelib/core/events.py	Thu Jul 24 08:15:26 2003
@@ -85,22 +85,11 @@
         """Returns the named connection."""
         return self._connections[name]
 
-    def addSources(self, sources):
-        """Connects sources with the object being loaded/stored.
-        """
-        self._sources.extend(sources)
-
-    def getSources(self):
-        """Returns [source]."""
-        return self._sources
-
 
 class LoadEvent (GatewayEvent):
     """Object loading event."""
 
     __implements__ = interfaces.ILoadEvent
-
-    hash_only = 0
 
 
 class StoreEvent (GatewayEvent):


=== Products/Ape/lib/apelib/core/gateways.py 1.6 => 1.6.2.1 ===
--- Products/Ape/lib/apelib/core/gateways.py:1.6	Wed Jul  9 11:39:59 2003
+++ Products/Ape/lib/apelib/core/gateways.py	Thu Jul 24 08:15:26 2003
@@ -91,6 +91,16 @@
         serials.sort()
         return tuple(serials)
 
+    def getSources(self, event):
+        """Returns data source information.  See IGateway.
+        """
+        res = {}
+        for gw in self._gws.values():
+            sources = gw.getSources(event)
+            if sources is not None:
+                res.update(sources)
+        return res
+
 
 class MappingGateway:
     """Gateway to a simple dictionary (primarily for testing).
@@ -117,4 +127,7 @@
         h = time.time()
         self.data[event.getKeychain()] = (data, h)
         return h
+
+    def getSources(self, event):
+        return None
 


=== Products/Ape/lib/apelib/core/interfaces.py 1.7.4.1 => 1.7.4.2 ===
--- Products/Ape/lib/apelib/core/interfaces.py:1.7.4.1	Wed Jul 23 00:12:41 2003
+++ Products/Ape/lib/apelib/core/interfaces.py	Thu Jul 24 08:15:26 2003
@@ -143,30 +143,10 @@
     def getConnection(name):
         """Returns the named connection."""
 
-    def addSources(sources):
-        """Connects sources with the object being loaded/stored.
-
-        A source is a (repository, location) pair.  The repository
-        defines the meaning of the location.  Both the repository
-        and source must be hashable.
-        """
-
-    def getSources():
-        """Returns [source]."""
-
 
 class ILoadEvent (IGatewayEvent):
     """Interface for events involved in loading objects."""
 
-    hash_only = Attribute(
-        'hash_only', """Set when only the hash is needed.
-
-        Sometimes the system only needs the hash value for an object
-        and not the full state.  When this attribute is set, the
-        gateway's load() method can choose to return None as the
-        state.  This is a read-only attribute.
-        """)
-
 
 class IStoreEvent (IGatewayEvent):
     """Interface for events involved in storing objects."""
@@ -363,10 +343,6 @@
         The hash value is either an integer or an object that is
         hashable using the Python hash() function.  The hashable
         object is used to detect storage conflicts.
-
-        If the hash_only attribute of the event is true, the system
-        only needs the hash value and the load() method can return
-        None as the state.
         """
 
     def store(event, data):
@@ -377,6 +353,20 @@
         Returns a new hash value.
         """
 
+    def getSources(event):
+        """Returns source information for a keychain.
+
+        The source information allows the system to poll for changes
+        to keep caches in sync with the data.  Where polling is not
+        necessary, gateways are free to return None.
+
+        The source information is a dictionary in the format:
+        {(repository, source): state}.  The repository must be an
+        ISourceRepository.  The source and state must be in a form
+        recognized by the repository.  Both the repository and source
+        must be hashable.
+        """
+
 
 class IClassifier(Interface):
     """Object classifier
@@ -540,4 +530,7 @@
     def close():
         """Closes resources.  Called only once."""
 
+
+class ISourceRepository(Interface):
+    """TBD"""
 


=== Products/Ape/lib/apelib/core/io.py 1.4.2.1 => 1.4.2.2 ===
--- Products/Ape/lib/apelib/core/io.py:1.4.2.1	Wed Jul 23 00:12:41 2003
+++ Products/Ape/lib/apelib/core/io.py	Thu Jul 24 08:15:26 2003
@@ -99,7 +99,7 @@
             initializer.init(event)
 
 
-    def load(self, keychain, hash_only=0):
+    def load(self, keychain):
         mapper = self._root_mapper
         mapper_names = []
         # Follow the keychain to find the right mapper.
@@ -113,8 +113,6 @@
             mapper_names.append(sub_mapper_name)
             mapper = mapper.getSubMapper(sub_mapper_name)
         event = LoadEvent(mapper, keychain, self._conn_map)
-        if hash_only:
-            event.hash_only = 1
         state, hash_value = mapper.getGateway().load(event)
         cs = ClassifiedState(state, classification, mapper_names)
         return event, cs, hash_value