Commit 277a8ffa authored by Christian Theune's avatar Christian Theune

- We really rely on the users to close the file handles correctly.

 - I made the IStreamIterator not gently close itself, but rely on e.g. Medusa
   closing it.
 - The tests now document the behaviour that a user should close the file handles.
parent 523473ef
......@@ -190,8 +190,6 @@ class BlobFile(file):
def next(self):
data = self.read(self.streamsize)
if not data:
if self.blob is not None:
self.blob._rc_decref(self.mode)
raise StopIteration
return data
......@@ -78,8 +78,27 @@ Now we can open it for writing again and e.g. append data:
Now we can read it:
>>> f4a = myblob.open("r")
>>> f4a.read()
'Hi, Blob!\nBlob is fine.'
>>> f4a.close()
Please, always remember closing an opened blob, otherwise you might get
blocked later on. Therefore you should avoid using the result of open()
without binding it to a name:
>>> myblob.open("r").read()
'Hi, Blob!\nBlob is fine.'
>>> f4b = myblob.open("a")
Traceback (most recent call last):
...
BlobError: Already opened for reading.
To clean that up, we have to commit or abort the current transaction, so the reference
counters for opened blob files get to a valid state again:
>>> import transaction
>>> transaction.commit()
We can read lines out of the blob too:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment