[Zodb-checkins] CVS: Zope3/src/zodb/storage - file.py:1.17

Jeremy Hylton jeremy@zope.com
Fri, 14 Mar 2003 14:41:01 -0500


Update of /cvs-repository/Zope3/src/zodb/storage
In directory cvs.zope.org:/tmp/cvs-serv17681/storage

Modified Files:
	file.py 
Log Message:
Simplify FileIterator because it always gets passed a filename.


=== Zope3/src/zodb/storage/file.py 1.16 => 1.17 ===
--- Zope3/src/zodb/storage/file.py:1.16	Fri Mar 14 12:18:53 2003
+++ Zope3/src/zodb/storage/file.py	Fri Mar 14 14:41:00 2003
@@ -663,14 +663,15 @@
 
     def close(self):
         self._file.close()
-        if hasattr(self,'_lock_file'):
+        if hasattr(self, '_lock_file'):
             self._lock_file.close()
         if self._tfile:
             self._tfile.close()
         try:
             self._save_index()
         except:
-            # XXX should log the error, though
+            logger.warn("Error saving storage index",
+                        exc_info=sys.exc_info())
             pass # We don't care if this fails.
 
     def setVersion(self, version):
@@ -1842,13 +1843,11 @@
 
     __implements__ = IStorageIterator
 
-    def __init__(self, file, start=None, stop=None):
-        if isinstance(file, str):
-            file = open(file, 'rb')
-        self._file = file
+    def __init__(self, filename, start=None, stop=None):
+        self._file = open(filename, "rb")
         self._read_metadata()
-        file.seek(0,2)
-        self._file_size = file.tell()
+        self._file.seek(0,2)
+        self._file_size = self._file.tell()
         self._pos = self._metadata_size
         assert start is None or isinstance(start, str)
         assert stop is None or isinstance(stop, str)