[Zope-CVS] CVS: Products/AdaptableStorage/mapper/interfaces - IGateway.py:1.2 IMapperEvent.py:1.4
Shane Hathaway
shane@zope.com
Sat, 1 Mar 2003 10:24:12 -0500
Update of /cvs-repository/Products/AdaptableStorage/mapper/interfaces
In directory cvs.zope.org:/tmp/cvs-serv19690/mapper/interfaces
Modified Files:
IGateway.py IMapperEvent.py
Log Message:
Renamed the 'serial' concept to 'hash' because it's easier to explain in
documentation. Also expanded ILoadEvent so that gateways can return the
hash without loading the entire object.
=== Products/AdaptableStorage/mapper/interfaces/IGateway.py 1.1 => 1.2 ===
--- Products/AdaptableStorage/mapper/interfaces/IGateway.py:1.1 Tue Dec 31 16:47:46 2002
+++ Products/AdaptableStorage/mapper/interfaces/IGateway.py Sat Mar 1 10:23:41 2003
@@ -38,20 +38,22 @@
def load(event):
"""Loads data.
- event is an IMapperEvent.
+ event is an ILoadEvent.
- Returns a pair containing the data and an object that acts as
- a serial number or a hash of the data. The serial number is
- either a time stamp or some other object that can be
- consistently compared to detect conflicts. The serial must be
- hashable.
+ Returns a pair containing the data and a hash of the data.
+ 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):
"""Stores data.
- event is an IMapperEvent.
+ event is an IStoreEvent.
- Returns a new serial.
+ Returns a new hash value.
"""
-
=== Products/AdaptableStorage/mapper/interfaces/IMapperEvent.py 1.3 => 1.4 ===
--- Products/AdaptableStorage/mapper/interfaces/IMapperEvent.py:1.3 Fri Feb 14 12:41:36 2003
+++ Products/AdaptableStorage/mapper/interfaces/IMapperEvent.py Sat Mar 1 10:23:41 2003
@@ -16,7 +16,7 @@
$Id$
"""
-from Interface import Interface
+from Interface import Interface, Attribute
class IMapperEvent (Interface):
"""The base interface for events in this package."""
@@ -27,6 +27,12 @@
def getKeychain():
"""Returns the keychain of the object being (de)serialized."""
+ def getKey():
+ """Returns the last element of the keychain.
+
+ For most purposes, the key can be used as an OID.
+ """
+
def makeKeychain(name, stored):
"""Generates a keychain for a subobject.
"""
@@ -34,6 +40,15 @@
class ILoadEvent (IMapperEvent):
"""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.
+ """)
class IStoreEvent (IMapperEvent):