[Zodb-checkins] CVS: ZODB/src/persistent - interfaces.py:1.4
wref.py:1.3
Tim Peters
tim.one at comcast.net
Mon Apr 19 17:19:41 EDT 2004
Update of /cvs-repository/ZODB/src/persistent
In directory cvs.zope.org:/tmp/cvs-serv9699/src/persistent
Modified Files:
interfaces.py wref.py
Log Message:
Whitespace normalization.
=== ZODB/src/persistent/interfaces.py 1.3 => 1.4 ===
--- ZODB/src/persistent/interfaces.py:1.3 Tue Feb 24 08:54:05 2004
+++ ZODB/src/persistent/interfaces.py Mon Apr 19 17:19:09 2004
@@ -286,7 +286,7 @@
unreferenced objects in memory. We assume that there is a good
chance the object will be used again soon, so keeping it memory
avoids the cost of recreating the object.
-
+
An ICache implementation is intended for use by an
IPersistentDataManager.
"""
@@ -307,7 +307,7 @@
"""Make all of the objects in oids ghosts.
`oids` is an iterable object that yields oids.
-
+
The cache must attempt to change each object to a ghost by
calling _p_deactivate().
@@ -330,7 +330,7 @@
def statistics():
"""Return dictionary of statistics about cache size.
-
+
Contains at least the following keys:
active -- number of active objects
ghosts -- number of ghost objects
=== ZODB/src/persistent/wref.py 1.2 => 1.3 ===
--- ZODB/src/persistent/wref.py:1.2 Wed Feb 18 21:59:30 2004
+++ ZODB/src/persistent/wref.py Mon Apr 19 17:19:09 2004
@@ -46,7 +46,7 @@
>>> WeakRef(ob) == ref
True
-
+
>>> ob2 = persistent.list.PersistentList([1])
>>> WeakRef(ob2) == ref
False
@@ -54,7 +54,7 @@
Lets save the reference and the referenced object in a database:
>>> db = ZODB.tests.util.DB()
-
+
>>> conn1 = db.open()
>>> conn1.root()['ob'] = ob
>>> conn1.root()['ref'] = ref
@@ -83,9 +83,9 @@
KeyError: 'ob'
Trying to dereference the reference returns None:
-
+
>>> conn3.root()['ref']()
-
+
Trying to get a hash, raises a type error:
>>> hash(conn3.root()['ref'])
@@ -94,7 +94,7 @@
TypeError: Weakly-referenced object has gone away
Always explicitly close databases: :)
-
+
>>> db.close()
"""
@@ -133,8 +133,8 @@
raise TypeError('Weakly-referenced object has gone away')
return self == other
-
-
+
+
class PersistentWeakKeyDictionary(Persistent):
"""Persistent weak key dictionary
@@ -170,9 +170,9 @@
[True, True, True, False]
We can add the dict and the referenced objects to a database:
-
+
>>> db = ZODB.tests.util.DB()
-
+
>>> conn1 = db.open()
>>> conn1.root()['p1'] = p1
>>> conn1.root()['d'] = d
@@ -217,7 +217,7 @@
Now if we access the dictionary in a new connection, it no longer
has p2:
-
+
>>> conn3 = db.open()
>>> d = conn3.root()['d']
>>> l = [(str(k), d[k], d.get(k)) for k in d]
@@ -227,17 +227,17 @@
It's worth nothing that that the versions of the dictionary in
conn1 and conn2 still have p2, because p2 is still in the caches
- for those connections.
+ for those connections.
Always explicitly close databases: :)
-
+
>>> db.close()
"""
# XXX it is expensive trying to load dead objects from the database.
# It would be helpful if the data manager/connection cached these.
-
+
def __init__(self, adict=None, **kwargs):
self.data = {}
if adict is not None:
@@ -259,13 +259,13 @@
if k() is not None
])
Persistent.__setstate__(self, state)
-
+
def __setitem__(self, key, value):
self.data[WeakRef(key)] = value
-
+
def __getitem__(self, key):
return self.data[WeakRef(key)]
-
+
def __delitem__(self, key):
del self.data[WeakRef(key)]
@@ -286,7 +286,7 @@
def __contains__(self, key):
return WeakRef(key) in self.data
-
+
def __iter__(self):
for k in self.data:
yield k()
@@ -297,6 +297,5 @@
else:
for k, v in adict.items():
self.data[WeakRef(k)] = v
-
+
# XXX Someone else can fill out the rest of the methods, with tests. :)
-
More information about the Zodb-checkins
mailing list