dabo Commit
Revision 2327
Date: 2006-10-10 17:45:39 -0700 (Tue, 10 Oct 2006)
Author: paul

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

Log:
Removed some dabo-specific calls from the base ReportWriter object, as this
object doesn't descend from dObject. Made reasonable default behavior and 
added the properties to dReportWriter instead. This fixes 
dabodemo/reports/invoice.py which has been broken for a while I'm sure.

Fixed ReportWriter to process the variables before the initial printing of the
static bands (before the iteration of the cursor begins), fixing potential
problems if the static bands (pageHeader/pageFooter, etc.) reference a report
variable.



Diff:
Modified: trunk/dabo/dReportWriter.py
===================================================================
--- trunk/dabo/dReportWriter.py 2006-10-10 00:55:37 UTC (rev 2326)
+++ trunk/dabo/dReportWriter.py 2006-10-11 00:45:39 UTC (rev 2327)
@@ -1,3 +1,4 @@
+from dabo.dLocalize import _
 from dabo.lib.reportWriter import ReportWriter
 from dabo.dObject import dObject
 
@@ -4,13 +5,41 @@
 
 # dReportWriter is simply a raw ReportWriter/dObject mixin:
 class dReportWriter(dObject, ReportWriter):
-       def _afterInit(self):
-               app = self.Application
-               if app is not None:
-                       self.home_dir = app.HomeDirectory
-               super(dReportWriter, self)._afterInit()
+       def _getEncoding(self):
+               try:
+                       v = self._encoding
+               except AttributeError:
+                       v = self._encoding = self.Application.Encoding
+               return v
 
+       def _setEncoding(self, val):
+               self._encoding = val
 
+
+       def _getHomeDirectory(self):
+               try:
+                       v = self._homeDirectory
+               except AttributeError:
+                       v = self._homeDirectory = self.Application.HomeDirectory
+               return v
+
+       def _setHomeDirectory(self, val):
+               self._homeDirectory = val
+
+
+       Encoding = property(_getEncoding, _setEncoding, None,
+               _("Specifies the encoding for unicode strings.  (str)"))
+
+       HomeDirectory = property(_getHomeDirectory, _setHomeDirectory, None,
+               _("""Specifies the home directory for the report.
+
+               Resources on disk (image files, etc.) will be looked for 
relative to the
+               HomeDirectory if specified with relative pathing. The 
HomeDirectory should
+               be the directory that contains the report form file. If you set 
+               self.ReportFormFile, HomeDirectory will be set for you 
automatically.
+               Otherwise, it will get set to 
self.Application.HomeDirectory."""))
+
+
 if __name__ == "__main__":
        ## run a test:
        rw = dReportWriter(Name="dReportWriter1", OutputFile="./dRW-test.pdf")

Modified: trunk/dabo/lib/reportWriter.py
===================================================================
--- trunk/dabo/lib/reportWriter.py      2006-10-10 00:55:37 UTC (rev 2326)
+++ trunk/dabo/lib/reportWriter.py      2006-10-11 00:45:39 UTC (rev 2327)
@@ -1323,6 +1323,9 @@
                
                        return y
 
+               # Need to process the variables before the first beginPage() in 
case
+               # any of the static bands reference the variables.
+               processVariables()
                beginPage()
 
                # Print the dynamic bands (Detail, GroupHeader, GroupFooter):
@@ -1677,7 +1680,7 @@
                try:
                        v = self._encoding
                except AttributeError:
-                       v = self._encoding =self.Application.Encoding
+                       v = self._encoding = "utf-8"
                return v
 
        def _setEncoding(self, val):
@@ -1688,7 +1691,7 @@
                try:
                        v = self._homeDirectory
                except AttributeError:
-                       v = self._homeDirectory = self.Application.HomeDirectory
+                       v = self._homeDirectory = os.getcwd()
                return v
 
        def _setHomeDirectory(self, val):
@@ -1844,8 +1847,7 @@
                Resources on disk (image files, etc.) will be looked for 
relative to the
                HomeDirectory if specified with relative pathing. The 
HomeDirectory should
                be the directory that contains the report form file. If you set 
-               self.ReportFormFile, HomeDirectory will be set for you 
automatically. 
-               Otherwise, HomeDirectory will be set to 
self.Application.HomeDirectory."""))
+               self.ReportFormFile, HomeDirectory will be set for you 
automatically."""))
 
        OutputFile = property(_getOutputFile, _setOutputFile, None,
                _("Specifies the output PDF file (name or file object)."))




_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-dev

Reply via email to