[Zope-Checkins] CVS: Zope/lib/python/Products/Transience - Transience.py:1.22 TransientObject.py:1.2

Chris McDonough chrism@zope.com
Mon, 26 Nov 2001 10:29:27 -0500


Update of /cvs-repository/Zope/lib/python/Products/Transience
In directory cvs.zope.org:/tmp/cvs-serv12262

Modified Files:
	Transience.py TransientObject.py 
Log Message:
Removed unnecessary imports.  Removed some debugging code.  Tests now pass on Cygwin.

=== Zope/lib/python/Products/Transience/Transience.py 1.21 => 1.22 ===
 
 import Globals
-from Globals import HTMLFile, MessageDialog
+from Globals import HTMLFile
 from TransienceInterfaces import ItemWithId,\
      StringKeyedHomogeneousItemContainer, TransientItemContainer
 from TransientObject import TransientObject
@@ -99,12 +99,11 @@
 from Persistence import Persistent
 from AccessControl import ClassSecurityInfo, getSecurityManager
 from AccessControl.SecurityManagement import newSecurityManager
-import AccessControl.SpecialUsers 
 from AccessControl.User import nobody
 from BTrees import OOBTree
 from BTrees.Length import Length
 from zLOG import LOG, WARNING, BLATHER
-import os, os.path, math, time, sys, random
+import os, math, time, sys, random
 
 DEBUG = os.environ.get('Z_TOC_DEBUG', '')
 
@@ -408,12 +407,11 @@
         try: self.__len__.set(0)
         except AttributeError: self.__len__ = self.getLen = Length()
 
-    def _getCurrentBucket(self, get_dump=0):
+    def _getCurrentBucket(self):
         # no timeout always returns last bucket
         if not self._timeout_secs:
+            DEBUG and DLOG('no timeout, returning first bucket')
             b, dump_after = self._ring._data[0]
-            if DEBUG:
-                DLOG('no timeout, returning first bucket')
             return b
         index = self._ring._index
         now = int(time.time())
@@ -425,9 +423,8 @@
         while 1:
             l = b, dump_after = self._ring._data[-1]
             if now > dump_after:
-                if DEBUG:
-                    DLOG('now is %s' % now)
-                    DLOG('dump_after for %s was %s, dumping'%(b, dump_after))
+                DEBUG and DLOG('dumping... now is %s' % now)
+                DEBUG and DLOG('dump_after for %s was %s'%(b, dump_after))
                 self._ring.turn()
                 # mutate elements in-place in the ring
                 new_dump_after = now + i
@@ -437,11 +434,8 @@
             else:
                 break
         if to_clean: self._clean(to_clean, index)
-        if get_dump:
-            return self._ring._data[0], dump_after, now
-        else:
-            b, dump_after = self._ring._data[0]
-            return b
+        b, dump_after = self._ring._data[0]
+        return b
 
     def _clean(self, bucket_set, index):
         # Build a reverse index.  Eventually, I'll keep this in another
@@ -473,20 +467,6 @@
             
         # finalize em
         self.notifyDestruct(trans_obs)
-
-    def _show(self):
-        """ debug method """
-        b,dump,now = self._getCurrentBucket(1)
-        ringdumps = map(lambda x: `x[1]`[-4], self._ring)
-        t = (
-            "now: "+`now`[-4:],
-            "dump_after: "+`dump`[-4:],
-            "ring_dumps: "+`ringdumps`,
-            "ring: " + `self._ring`
-             )
-
-        for x in t:
-            print x
 
     security.declareProtected(MGMT_SCREEN_PERM, 'nudge')
     def nudge(self):


=== Zope/lib/python/Products/Transience/TransientObject.py 1.1 => 1.2 ===
 
 from Persistence import Persistent
-from Acquisition import Implicit, aq_base
+from Acquisition import Implicit
 import time, random, sys
 from TransienceInterfaces import ItemWithId, Transient, DictionaryLike,\
      TTWDictionary, ImmutablyValuedMappingOfPickleableObjects