[Checkins] SVN: zope.file/branches/ajung-blobs/src/zope/file/ savepoint

Andreas Jung andreas at andreas-jung.com
Mon Feb 26 17:45:32 EST 2007


Log message for revision 72845:
  savepoint
  

Changed:
  U   zope.file/branches/ajung-blobs/src/zope/file/README.txt
  U   zope.file/branches/ajung-blobs/src/zope/file/file.py

-=-
Modified: zope.file/branches/ajung-blobs/src/zope/file/README.txt
===================================================================
--- zope.file/branches/ajung-blobs/src/zope/file/README.txt	2007-02-26 22:42:51 UTC (rev 72844)
+++ zope.file/branches/ajung-blobs/src/zope/file/README.txt	2007-02-26 22:45:31 UTC (rev 72845)
@@ -98,24 +98,26 @@
 We can now use a reader to see that the data has been written to the
 file::
 
-  >>> r = f.open("rb")
-  >>> r.read()
-  'some text more text'
-  >>> r.read()
-  ''
-  >>> r.tell()
-  19
+  >>> w = f.open("w")
+  >>> w.write('some text more text')
+  >>> w.write(" still more")
+  >>> w.close()
+  >>> f.size
+  30
 
 
+Now create a new reader and let's perform some seek operations.
 
+  >>> r = f.open()
+
 The reader also has a `seek()` method that can be used to back up or
 skip forward in the data stream.  Simply passing an offset argument,
 we see that the current position is moved to that offset from the
 start of the file::
 
-  >>> r.seek(10)
+  >>> r.seek(20)
   >>> r.read()
-  'more text'
+  'still more'
 
 That's equivalent to passing 0 as the `whence` argument::
 

Modified: zope.file/branches/ajung-blobs/src/zope/file/file.py
===================================================================
--- zope.file/branches/ajung-blobs/src/zope/file/file.py	2007-02-26 22:42:51 UTC (rev 72844)
+++ zope.file/branches/ajung-blobs/src/zope/file/file.py	2007-02-26 22:45:31 UTC (rev 72845)
@@ -104,8 +104,7 @@
         raise TypeError("%s.%s instance is not picklable"
                         % (cls.__module__, cls.__name__))
 
-    @property
-    def stream(self):
+    def _get_stream(self):
         return self._stream
 
     def _close(self):
@@ -122,22 +121,22 @@
     def read(self, size=-1):
         if self._closed:
             raise ValueError("I/O operation on closed file")
-        return self.stream.read(size)
+        return self._get_stream().read()
 
     def seek(self, offset, whence=0):
         if self._closed:
             raise ValueError("I/O operation on closed file")
         if whence not in (0, 1, 2):
             raise ValueError("illegal value for `whence`")
-        self.stream.seek(offset, whence)
+        self._get_stream().seek(offset, whence)
 
     def tell(self):
         if self._closed:
             raise ValueError("I/O operation on closed file")
-        return int(self.stream.tell())
+        return int(self._get_stream().tell())
 
     def _close(self):
-        self.stream.close()
+        self._get_stream().close()
 
 
 class Writer(Accessor):
@@ -150,13 +149,13 @@
     def flush(self):
         if self._closed:
             raise ValueError("I/O operation on closed file")
-        self.stream.flush()
+        self._get_stream().flush()
     
     def write(self, data):
         if self._closed:
             raise ValueError("I/O operation on closed file")
-        self.stream.write(data)
+        self._get_stream().write(data)
 
     def _close(self):
-        self.stream.close()
+        self._get_stream().close()
 



More information about the Checkins mailing list