From 3f58706e5ea60b7e8e7823cff31044d20bde3b7d Mon Sep 17 00:00:00 2001
From: Vincent Pelletier <vincent@nexedi.com>
Date: Wed, 27 Aug 2014 10:05:07 +0200
Subject: [PATCH] BigFile: Simplify use of iterator.

---
 product/ERP5/Document/BigFile.py | 24 ++++++------------------
 1 file changed, 6 insertions(+), 18 deletions(-)

diff --git a/product/ERP5/Document/BigFile.py b/product/ERP5/Document/BigFile.py
index 93a6807363..3576127359 100644
--- a/product/ERP5/Document/BigFile.py
+++ b/product/ERP5/Document/BigFile.py
@@ -201,12 +201,8 @@ class BigFile(File):
           if isinstance(data, str):
             RESPONSE.write(data[start:end])
             return True
-          iterator = data.iterate(start, end-start)
-          try:
-            while 1:
-              RESPONSE.write(iterator.next())
-          except StopIteration:
-            pass
+          for chunk in data.iterate(start, end-start):
+            RESPONSE.write(chunk)
           return True
 
         else:
@@ -251,12 +247,8 @@ class BigFile(File):
               RESPONSE.write(data[start:end])
 
             else:
-              iterator = data.iterate(start, end-start)
-              try:
-                while 1:
-                  RESPONSE.write(iterator.next())
-              except StopIteration:
-                pass
+              for chunk in data.iterate(start, end-start):
+                RESPONSE.write(chunk)
 
           RESPONSE.write('\r\n--%s--\r\n' % boundary)
           return True
@@ -301,12 +293,8 @@ class BigFile(File):
 
     if data is None:
       return ''
-    iterator = data.iterate()
-    try:
-      while 1:
-        RESPONSE.write(iterator.next())
-    except StopIteration:
-      pass
+    for chunk in data.iterate():
+      RESPONSE.write(chunk)
     return ''
 
   security.declareProtected(Permissions.ModifyPortalContent,'PUT')
-- 
2.30.9