dabo Commit
Revision 7106
Date: 2012-03-06 15:01:40 -0800 (Tue, 06 Mar 2012)
Author: Paul
Trac: http://trac.dabodev.com/changeset/7106

Changed:
U   trunk/dabo/dReportWriter.py
U   trunk/dabo/lib/reportWriter.py

Log:
Optimizations of report writer. 


Diff:
Modified: trunk/dabo/dReportWriter.py
===================================================================
--- trunk/dabo/dReportWriter.py 2012-03-05 20:24:18 UTC (rev 7105)
+++ trunk/dabo/dReportWriter.py 2012-03-06 23:01:40 UTC (rev 7106)
@@ -35,6 +35,7 @@
        def _onReportEnd(self):
                super(dReportWriter, self)._onReportEnd()
                self.raiseEvent(dabo.dEvents.ReportEnd)
+               self._updateProgress(force=True)
                #self._hideProgress()  ## Let the form controlling the progress 
gauge do this (less blinky)
 
        def _onReportIteration(self):
@@ -50,11 +51,12 @@
                        win.show()
                        win.Form.fitToSizer()
 
-       def _updateProgress(self):
-               win = self.ProgressControl
-               if win:
-                       win.updateProgress(self.RecordNumber+1, 
len(self.Cursor))
-                       dabo.ui.yieldUI(_safe=True)
+       def _updateProgress(self, force=False):
+               if force or self.RecordNumber % 10 == 0:
+                       win = self.ProgressControl
+                       if win:
+                               win.updateProgress(self.RecordNumber, 
len(self.Cursor))
+                               dabo.ui.yieldUI(_safe=True)
 
        def _hideProgress(self):
                win = self.ProgressControl

Modified: trunk/dabo/lib/reportWriter.py
===================================================================
--- trunk/dabo/lib/reportWriter.py      2012-03-05 20:24:18 UTC (rev 7105)
+++ trunk/dabo/lib/reportWriter.py      2012-03-06 23:01:40 UTC (rev 7106)
@@ -9,6 +9,7 @@
 import sys
 import os
 from dabo.dLocalize import _
+
 ######################################################
 # Very first thing: check for required libraries:
 _failedLibs = []
@@ -246,6 +247,8 @@
                self.insertRequiredElements()
 
        def __getattr__(self, att):
+               if att == "_resolvedReport":
+                       raise AttributeError
                rw = self.Report.reportWriter
 
                # 1) Try mapping the requested attribute to the reportWriter. 
This will handle
@@ -466,12 +469,21 @@
 
 
        def _getReport(self):
+               ret = getattr(self, "_resolvedReport", None)
+               if ret:
+                       return ret
                parent = self
                while not isinstance(parent, Report):
                        parent = parent.parent
+               self._resolvedReport = parent
                return parent
 
 
+       def _getReportForm(self):
+               return self.Report.reportWriter.ReportForm
+       ReportForm = property(_getReportForm)
+
+
        def _getVariables(self):
                rw = self.Report.reportWriter
                if rw is None:
@@ -2040,7 +2052,6 @@
                        self.draw(obj, (x,y))
                        del obj["expr_pagecount"]
 
-
        def write(self, save=True):
                """Write the PDF file based on the ReportForm spec.
 
@@ -2141,7 +2152,6 @@
 
                def printBand(band, y=None, group=None, deferred=None):
                        """Generic function for printing any band."""
-
                        _form = self.ReportForm
                        page = _form["Page"]
 
@@ -2480,6 +2490,7 @@
 
                        self._onReportIteration()
 
+                       startNewPage = False
                # print group footers for previous group if necessary:
                        if cursor_idx > 0:
                                # First pass, iterate through the groups 
outer->inner, and if any group
@@ -2490,30 +2501,23 @@
                                        if resetCurVals or vv["curVal"] != 
group.getProp("expr"):
                                                resetCurVals = True
                                                vv["curVal"] = 
UNINITIALIZED_VALUE
+                                               if 
group.getProp("StartOnNewPage"):
+                                                       startNewPage = True
 
-                               # Second pass, iterate through the groups 
inner->outer, and print the
-                               # group footers for groups that have changed.
-                               for idx, group in enumerate(groupsDesc):
-                                       vv = self._groupValues[group["expr"]]
-                                       if vv["curVal"] != 
group.getProp("expr"):
-                                               # We need to temporarily move 
back to the last record so that the
-                                               # group footer reflects what 
the user expects.
-                                               self.Record = _lastRecord
-                                               y = printBand("groupFooter", y, 
group)
-                                               self.Record = record
+                               if resetCurVals:
+                                       # Second pass, iterate through the 
groups inner->outer, and print the
+                                       # group footers for groups that have 
changed.
+                                       for idx, group in enumerate(groupsDesc):
+                                               vv = 
self._groupValues[group["expr"]]
+                                               if vv["curVal"] != 
group.getProp("expr"):
+                                                       # We need to 
temporarily move back to the last record so that the
+                                                       # group footer reflects 
what the user expects.
+                                                       self.Record = 
_lastRecord
+                                                       y = 
printBand("groupFooter", y, group)
+                                                       self.Record = record
 
                        # print group headers for this group if necessary:
 
-                       # First, start a new page if necessary. But only one 
new page:
-                       startNewPage = False
-                       if self.RecordNumber > 0:
-                               # Find out if any group is going to start on a 
new page.
-                               for group in groups:
-                                       curVal = 
self._groupValues[group["expr"]]["curVal"]
-                                       if group.getProp("StartOnNewPage") and 
curVal != group.getProp("expr"):
-                                               startNewPage = True
-                                               break
-
                        if startNewPage:
                                # We are starting a new page because a group 
expr changed; temporarily put
                                # the record back on the last one to print the 
footer that is expected.
@@ -2524,8 +2528,7 @@
                                self.Canvas.showPages()
                                beginPage()
                                y = None
-
-                       if not startNewPage and cursor_idx > 0:
+                       elif cursor_idx > 0:
                                # needed variable processing hasn't yet occured 
for this record:
                                processVariables()
 



_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-dev
Searchable Archives: http://leafe.com/archives/search/dabo-dev
This message: 
http://leafe.com/archives/byMID/[email protected]

Reply via email to