[Zodb-checkins] SVN: ZODB/branches/ctheune-blobsupport/src/ZODB/Blobs/Blob.txt Add a few tests for readline, seek, tell, and truncate.

Chris McDonough chrism at plope.com
Thu Mar 24 03:04:13 EST 2005


Log message for revision 29660:
  Add a few tests for readline, seek, tell, and truncate.
  

Changed:
  U   ZODB/branches/ctheune-blobsupport/src/ZODB/Blobs/Blob.txt

-=-
Modified: ZODB/branches/ctheune-blobsupport/src/ZODB/Blobs/Blob.txt
===================================================================
--- ZODB/branches/ctheune-blobsupport/src/ZODB/Blobs/Blob.txt	2005-03-24 08:00:22 UTC (rev 29659)
+++ ZODB/branches/ctheune-blobsupport/src/ZODB/Blobs/Blob.txt	2005-03-24 08:04:13 UTC (rev 29660)
@@ -81,4 +81,40 @@
     >>> myblob.open("r").read()
     'Hi, Blob!\nBlob is fine.'
 
+We can read lines out of the blob too:
 
+    >>> f5 = myblob.open("r")
+    >>> f5.readline()
+    'Hi, Blob!\n'
+    >>> f5.readline()
+    'Blob is fine.'
+    >>> f5.close()
+
+We can seek to certain positions in a blob and read portions of it:
+
+    >>> f6 = myblob.open('r')
+    >>> f6.seek(4)
+    >>> int(f6.tell())
+    4
+    >>> f6.read(5)
+    'Blob!'
+    >>> f6.close()
+
+We can use the object returned by a blob open call as an iterable:
+
+    >>> f7 = myblob.open('r')
+    >>> for line in f7:
+    ...     print line
+    Hi, Blob!
+    Blob is fine.
+    >>> f7.close()
+
+We can truncate a blob:
+
+    >>> f8 = myblob.open('a')
+    >>> f8.truncate(0)
+    >>> f8.close()
+    >>> f8 = myblob.open('r')
+    >>> f8.read()
+    ''
+    >>> f8.close()



More information about the Zodb-checkins mailing list