Commit 3f58706e authored by Vincent Pelletier's avatar Vincent Pelletier

BigFile: Simplify use of iterator.

parent 2f9dc41e
...@@ -201,12 +201,8 @@ class BigFile(File): ...@@ -201,12 +201,8 @@ class BigFile(File):
if isinstance(data, str): if isinstance(data, str):
RESPONSE.write(data[start:end]) RESPONSE.write(data[start:end])
return True return True
iterator = data.iterate(start, end-start) for chunk in data.iterate(start, end-start):
try: RESPONSE.write(chunk)
while 1:
RESPONSE.write(iterator.next())
except StopIteration:
pass
return True return True
else: else:
...@@ -251,12 +247,8 @@ class BigFile(File): ...@@ -251,12 +247,8 @@ class BigFile(File):
RESPONSE.write(data[start:end]) RESPONSE.write(data[start:end])
else: else:
iterator = data.iterate(start, end-start) for chunk in data.iterate(start, end-start):
try: RESPONSE.write(chunk)
while 1:
RESPONSE.write(iterator.next())
except StopIteration:
pass
RESPONSE.write('\r\n--%s--\r\n' % boundary) RESPONSE.write('\r\n--%s--\r\n' % boundary)
return True return True
...@@ -301,12 +293,8 @@ class BigFile(File): ...@@ -301,12 +293,8 @@ class BigFile(File):
if data is None: if data is None:
return '' return ''
iterator = data.iterate() for chunk in data.iterate():
try: RESPONSE.write(chunk)
while 1:
RESPONSE.write(iterator.next())
except StopIteration:
pass
return '' return ''
security.declareProtected(Permissions.ModifyPortalContent,'PUT') security.declareProtected(Permissions.ModifyPortalContent,'PUT')
......
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