[Zope-CVS] CVS: Products/Transience - Transience.py:1.8 TransienceInterfaces.py:1.6 __init__.py:1.3
Matthew T. Kromer
matt@zope.com
Fri, 2 Nov 2001 15:44:52 -0500
Update of /cvs-repository/Products/Transience
In directory cvs.zope.org:/tmp/cvs-serv12259
Modified Files:
Transience.py TransienceInterfaces.py __init__.py
Log Message:
Updated Transience documentation
=== Products/Transience/Transience.py 1.7 => 1.8 ===
import math
import time
+import sys
+import random
_notfound = []
_marker = []
@@ -605,7 +607,8 @@
#
def __init__(self, id, parent=None):
- self.id = id
+ self.name = id
+ self.id = self._generateUniqueId()
self._parent = parent
self._container = {}
self._created = self._last_accessed = time()
@@ -723,7 +726,19 @@
# other objects (eliminates read conflicts).
return 1
- getName = getId
+ def getName(self):
+ return self.name
+
+ def _generateUniqueId(self):
+ return str(time())+str(random.randint(0,sys.maxint-1))
+
+ def __str__(self):
+ result = "<table>\n"
+ for (key, value) in self.items():
+ result = result + "<tr><th>%s</th><td>%s</td></tr>\n" % (key, value)
+
+ result= result + "</table>"
+ return result
Globals.InitializeClass(TransientObjectContainer)
Globals.InitializeClass(TransientObject)
=== Products/Transience/TransienceInterfaces.py 1.5 => 1.6 ===
-Transient object and transient object container interfaces.
+Transient Objects
+
+ TransientObjectContainers implement:
+
+ - ItemWithId
+
+ - StringKeyedHomogenousItemContainer
+
+ - TransientItemContainer
+
+ In particular, one uses the 'new_ _or_ _existing' method on
+ TransientObjectContainers to retrieve or create a TransientObject based
+ on a given string key.
+
+ If add or delete notifications are registered with the container, they
+ will be called back when items in the container are added or deleted,
+ with the item and the container as arguments. The callbacks may be
+ registered either as bound methods, functions, or named paths in Zope.
+
+ TransientObjects implement:
+
+ - ItemWithId
+
+ - Transient
+
+ - DictionaryLike
+
+ - TTWDictionary
+
+ - ImmutablyValuedMappingOfPickleableObjects
+
"""
import Interface
@@ -78,17 +108,17 @@
class TTWDictionary(DictionaryLike, ItemWithId):
def set(self, k, v):
"""
- Call __setitem__ with key k, value v.
+ Call _ _setitem_ _ with key k, value v.
"""
def delete(self, k):
"""
- Call __delitem__ with key k.
+ Call _ _delitem_ _ with key k.
"""
def __guarded_setitem__(self, k, v):
"""
- Call __setitem__ with key k, value v.
+ Call _ _setitem_ _ with key k, value v.
"""
class ImmutablyValuedMappingOfPickleableObjects(Interface.Base):
@@ -103,10 +133,11 @@
Returns the value associated with key k.
Note that no guarantee is made to persist changes made to mutable
- objects obtained via __getitem__, even if they support the
- ZODB Persistence interface. In order to ensure that changes to
- mutable values are persisted, you need to explicitly put the value back
- in to the mapping via __setitem__.
+ objects obtained via _ _getitem_ _, even if
+ they support the ZODB Persistence interface. In order to ensure
+ that changes to mutable values are persisted, you need to explicitly
+ put the value back in to the mapping via the
+ _ _setitem_ _.
"""
def __delitem__(self, k):
@@ -117,9 +148,9 @@
class HomogeneousItemContainer(Interface.Base):
"""
An object which:
- 1. Contains zero or more subobjects, all of the same type.
- 2. Is responsible for the creation of its subobjects.
- 3. Allows for the access of a subobject by key.
+ 1. Contains zero or more subobjects, all of the same type.
+ 2. Is responsible for the creation of its subobjects.
+ 3. Allows for the access of a subobject by key.
"""
def getSubobjectInterface(self):
"""
=== Products/Transience/__init__.py 1.2 => 1.3 ===
)
context.registerHelp()
+ context.registerHelpTitle('Zope Help')