summaryrefslogtreecommitdiffstats
path: root/src/lib/Server/Reports/utils.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/Server/Reports/utils.py')
-rwxr-xr-xsrc/lib/Server/Reports/utils.py34
1 files changed, 13 insertions, 21 deletions
diff --git a/src/lib/Server/Reports/utils.py b/src/lib/Server/Reports/utils.py
index 04fdbf985..6010f366b 100755
--- a/src/lib/Server/Reports/utils.py
+++ b/src/lib/Server/Reports/utils.py
@@ -1,25 +1,10 @@
"""Helper functions for reports"""
from django.conf.urls.defaults import *
import re
-import sys
"""List of filters provided by filteredUrls"""
filter_list = ('server', 'state')
-def increment(self):
- """Return the next object from our array and fetch from the
- database when needed"""
- if self.block_count + self.count - self.step == self.max:
- raise StopIteration
- if self.block_count == 0 or self.count == self.step:
- # Without list() this turns into LIMIT 1 OFFSET x queries
- self.data = list(self.obj.all()[self.block_count: \
- (self.block_count + self.step)])
- self.block_count += self.step
- self.count = 0
- self.count += 1
- return self.data[self.count - 1]
-
class BatchFetch(object):
"""Fetch Django objects in smaller batches to save memory"""
@@ -35,12 +20,19 @@ class BatchFetch(object):
def __iter__(self):
return self
- if sys.hexversion > 0x03000000:
- def __next__(self):
- return increment(self)
- else:
- def next(self):
- return increment(self)
+ def __next__(self):
+ """Return the next object from our array and fetch from the
+ database when needed"""
+ if self.block_count + self.count - self.step == self.max:
+ raise StopIteration
+ if self.block_count == 0 or self.count == self.step:
+ # Without list() this turns into LIMIT 1 OFFSET x queries
+ self.data = list(self.obj.all()[self.block_count: \
+ (self.block_count + self.step)])
+ self.block_count += self.step
+ self.count = 0
+ self.count += 1
+ return self.data[self.count - 1]
def generateUrls(fn):