dabo Commit
Revision 1381
Date: 2005-09-26 07:58:57 -0700 (Mon, 26 Sep 2005)
Author: paul
Changed:
U trunk/dabo/dReportWriter.py
U trunk/dabo/db/dbMySQL.py
U trunk/dabo/lib/reportWriter.py
Log:
Added importing of locale to reportwriter so that it can be called from user
expressions. I'm going to eventually rework all this so that user reports
can specify which modules to import, but for now this suffices.
Added a home_dir attr to the reportwriter that will be used when searching
for resources on the path (images, for example) and set home_dir to
app.HomeDirectory at startup.
Diff:
Modified: trunk/dabo/dReportWriter.py
===================================================================
--- trunk/dabo/dReportWriter.py 2005-09-26 08:15:24 UTC (rev 1380)
+++ trunk/dabo/dReportWriter.py 2005-09-26 14:58:57 UTC (rev 1381)
@@ -2,7 +2,12 @@
from dabo.common.dObject import dObject
# dReportWriter is simply a raw ReportWriter/dObject mixin:
-class dReportWriter(dObject, ReportWriter): pass
+class dReportWriter(dObject, ReportWriter):
+ def _afterInit(self):
+ app = self.Application
+ if app is not None:
+ self.home_dir = app.HomeDirectory
+ super(dReportWriter, self)._afterInit()
if __name__ == "__main__":
Modified: trunk/dabo/db/dbMySQL.py
===================================================================
--- trunk/dabo/db/dbMySQL.py 2005-09-26 08:15:24 UTC (rev 1380)
+++ trunk/dabo/db/dbMySQL.py 2005-09-26 14:58:57 UTC (rev 1381)
@@ -78,7 +78,7 @@
def getFields(self, tableName):
if not tableName:
- return tuple([])
+ return tuple()
tempCursor = self._connection.cursor()
tempCursor.execute("describe %s" % tableName)
rs = tempCursor.fetchall()
Modified: trunk/dabo/lib/reportWriter.py
===================================================================
--- trunk/dabo/lib/reportWriter.py 2005-09-26 08:15:24 UTC (rev 1380)
+++ trunk/dabo/lib/reportWriter.py 2005-09-26 14:58:57 UTC (rev 1381)
@@ -1,6 +1,7 @@
import copy
import datetime
import decimal
+import locale
import sys
import os
######################################################
@@ -109,6 +110,9 @@
default_padTop = 0
default_padBottom = 0
+ home_dir = "."
+
+
def draw(self, object, origin):
"""Draw the given object on the Canvas.
@@ -421,8 +425,12 @@
# "natural" state 1:1 pixel:point, which could
flow out of the object's
# width/height, resulting in clipping.
width, height = None, None
- c.drawImage(eval(object["expr"]), 0, 0, width, height,
mask)
+ imageFile = eval(object["expr"])
+ if not os.path.exists(imageFile):
+ imageFile = os.path.join(self.home_dir,
imageFile)
+ c.drawImage(imageFile, 0, 0, width, height, mask)
+
## All done, restore the canvas state to how we found it
(important because
## rotating, scaling, etc. are cumulative, not absolute and we
don't want
## to start with a canvas in an unknown state.)
_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-dev