Index: /main/waeup.uniben/trunk/src/waeup/uniben/scripts.py
===================================================================
--- /main/waeup.uniben/trunk/src/waeup/uniben/scripts.py	(revision 13201)
+++ /main/waeup.uniben/trunk/src/waeup/uniben/scripts.py	(revision 13202)
@@ -81,50 +81,4 @@
 
 
-def export():
-    """Main function.
-    """
-    closables = init_dbs()
-    conn = closables[0].open()
-    uni = get_university(conn)
-    studs = uni['students']
-
-    parts = partition(studs)
-    print(parts)
-
-    #parts = [(0, 0, 100), ]
-    #parts = [(0, 0, 4999), (1, 5000, 9999), (2, 10000, 14999)]
-    #parts = [(0, 0, 14999), ]
-    #parts = [(0, 0, 160000), ]
-
-    workdir = tempfile.mkdtemp()
-
-    t1 = time.time()
-    conn.close()  # every loop will reopen the connection
-    for p_num, start, end in parts:
-        conn = closables[0].open()
-        uni = get_university(conn)
-        studs = uni['students']
-        curr_path = os.path.join(workdir, "myexport%s.csv" % p_num)
-        export_part(studs, p_num, start, end, curr_path)
-        conn.close()
-    print("Result in %s" % workdir)
-    t2 = time.time()
-    print("Elapsed: %s secs" % (t2 - t1))
-
-
-def export_part(container, part_num, start, end, path):
-    import psutil  # late import. Don't want to make it waeup.uniben req.
-    PROC = psutil.Process(os.getpid())
-    gc.collect()
-    mem1 = PROC.get_memory_info().rss
-    print("  Export %s-%s to %s (mem: %s)" % (start, end, path, mem1))
-    tp1 = time.time()
-    exporter = getUtility(ICSVExporter, name="students")
-    exporter.export(get_all_students(container, start, end), path)
-    tp2 = time.time()
-    mem2 = PROC.get_memory_info().rss
-    print("  Done (%s secs, mem: %s)" % (tp2 - tp1, mem2))
-
-
 def get_all_students(container, cnt_from=0, cnt_to=0):
     cnt = 0
@@ -165,2 +119,48 @@
         (idx, start, min(start + part_size - 1, num - 1))
         for idx, start in enumerate(range(0, num, part_size))]
+
+
+def export_part(container, part_num, start, end, path):
+    import psutil  # late import. Don't want to make it waeup.uniben req.
+    PROC = psutil.Process(os.getpid())
+    gc.collect()
+    mem1 = PROC.get_memory_info().rss
+    print("  Export %s-%s to %s (mem: %s)" % (start, end, path, mem1))
+    tp1 = time.time()
+    exporter = getUtility(ICSVExporter, name="students")
+    exporter.export(get_all_students(container, start, end), path)
+    tp2 = time.time()
+    mem2 = PROC.get_memory_info().rss
+    print("  Done (%s secs, mem: %s)" % (tp2 - tp1, mem2))
+
+
+def export():
+    """Main function.
+    """
+    closables = init_dbs()
+    conn = closables[0].open()
+    uni = get_university(conn)
+    studs = uni['students']
+
+    parts = partition(studs)
+    print(parts)
+
+    #parts = [(0, 0, 100), ]
+    #parts = [(0, 0, 4999), (1, 5000, 9999), (2, 10000, 14999)]
+    #parts = [(0, 0, 14999), ]
+    #parts = [(0, 0, 160000), ]
+
+    workdir = tempfile.mkdtemp()
+
+    t1 = time.time()
+    conn.close()  # every loop will reopen the connection
+    for p_num, start, end in parts:
+        conn = closables[0].open()
+        uni = get_university(conn)
+        studs = uni['students']
+        curr_path = os.path.join(workdir, "myexport%s.csv" % p_num)
+        export_part(studs, p_num, start, end, curr_path)
+        conn.close()
+    print("Result in %s" % workdir)
+    t2 = time.time()
+    print("Elapsed: %s secs" % (t2 - t1))
