dabo Commit
Revision 2230
Date: 2006-06-21 05:02:03 -0700 (Wed, 21 Jun 2006)
Author: ed

Changed:
U   trunk/dabo/biz/dBizobj.py
U   trunk/dabo/dApp.py
U   trunk/dabo/db/dBackend.py
U   trunk/dabo/db/dCursorMixin.py
U   trunk/dabo/lib/connParser.py
U   trunk/dabo/lib/xmltodict.py
U   trunk/dabo/settings.py

Log:
Added the default encoding as an attribute of the dabo module itself, via the 
dabo/settings.py file. You can now reference the default encoding from anywhere 
within Dabo by using dabo.defaultEncoding, and you can override this by 
modifying your settings_override.py file.


Diff:
Modified: trunk/dabo/biz/dBizobj.py
===================================================================
--- trunk/dabo/biz/dBizobj.py   2006-06-20 17:03:00 UTC (rev 2229)
+++ trunk/dabo/biz/dBizobj.py   2006-06-21 12:02:03 UTC (rev 2230)
@@ -1398,7 +1398,10 @@
                if cursor is not None:
                        ret = cursor.Encoding
                if ret is None:
-                       ret = self.Application.Encoding
+                       if self.Application:
+                               ret = self.Application.Encoding
+                       else:
+                               ret = dabo.defaultEncoding
                return ret
 
        def _setEncoding(self, val):

Modified: trunk/dabo/dApp.py
===================================================================
--- trunk/dabo/dApp.py  2006-06-20 17:03:00 UTC (rev 2229)
+++ trunk/dabo/dApp.py  2006-06-21 12:02:03 UTC (rev 2230)
@@ -572,7 +572,7 @@
        def _getEncoding(self):
                ret = locale.getlocale()[1]
                if ret is None:
-                       ret = "utf-8"
+                       ret = dabo.defaultEncoding
                return ret
                
 

Modified: trunk/dabo/db/dBackend.py
===================================================================
--- trunk/dabo/db/dBackend.py   2006-06-20 17:03:00 UTC (rev 2229)
+++ trunk/dabo/db/dBackend.py   2006-06-21 12:02:03 UTC (rev 2230)
@@ -23,6 +23,8 @@
                self._connection = None
                if self.Application:
                        self._encoding = self.Application.Encoding
+               else:
+                       self._encoding = dabo.defaultEncoding
 
 
        def isValidModule(self):

Modified: trunk/dabo/db/dCursorMixin.py
===================================================================
--- trunk/dabo/db/dCursorMixin.py       2006-06-20 17:03:00 UTC (rev 2229)
+++ trunk/dabo/db/dCursorMixin.py       2006-06-21 12:02:03 UTC (rev 2230)
@@ -252,7 +252,7 @@
                                                        except 
UnicodeDecodeError, e:
                                                                # Try some 
common encodings:
                                                                ok = False
-                                                               for enc in 
("utf8", "latin-1"):
+                                                               for enc in 
("utf-8", "latin-1", "iso-8859-1"):
                                                                        if enc 
!= self.Encoding:
                                                                                
try:
                                                                                
        row[fld]= unicode(val, enc)
@@ -882,11 +882,16 @@
 
 
        def __saverow(self, rec):
+       
+               print "SAVEROW", rec
                newrec =  rec.has_key(kons.CURSOR_NEWFLAG)
                mem = rec[kons.CURSOR_MEMENTO]
                diff = self.makeUpdDiff(rec, newrec)
 
                if diff:
+                       
+                       print "diff", diff
+                       
                        if newrec:
                                flds = ""
                                vals = ""
@@ -906,9 +911,9 @@
                                                
                                        # Append the field and its value.
                                        flds += ", " + kk
-                                       
                                        # add value to expression
                                        vals += ", %s" % 
(self.formatForQuery(vv),)
+                                       
                                # Trim leading comma-space from the strings
                                flds = flds[2:]
                                vals = vals[2:]
@@ -916,8 +921,15 @@
 
                        else:
                                pkWhere = self.makePkWhere(rec)
+                               
+                               print "PKJWHERFE", pkWhere
                                updClause = self.makeUpdClause(diff)
+                               
+                               print "UPD", updClause
+                               
                                sql = "update %s set %s where %s" % 
(self.Table, updClause, pkWhere)
+                               
+                               print "SQL", sql
 
                        newPKVal = None
                        if newrec and self.AutoPopulatePK:
@@ -1354,13 +1366,20 @@
                ret = ""
                tblPrefix = self.BackendObject.getUpdateTablePrefix(self.Table)
                
+               print "IN MAKE UP", diff
+               
                for fld, val in diff.items():
+               
+                       print "WOW"
+                       print "FLDVAL", fld, val
+                       
                        # Skip the fields that are not to be updated.
                        if fld in self.getNonUpdateFields():
                                continue
                        if ret:
                                ret += ", "
                        
+                       print "MAKEUP", ret, val
                        ret += tblPrefix + fld + " = " + 
self.formatForQuery(val)                       
                return ret
 
@@ -1424,7 +1443,9 @@
                """ Format any value for the backend """
                ret = val
                if self.BackendObject:
+                       print "BEFORE BACKEND"
                        ret = self.BackendObject.formatForQuery(val)
+                       print "AFTER BACKEND"
                return ret
 
        

Modified: trunk/dabo/lib/connParser.py
===================================================================
--- trunk/dabo/lib/connParser.py        2006-06-20 17:03:00 UTC (rev 2229)
+++ trunk/dabo/lib/connParser.py        2006-06-21 12:02:03 UTC (rev 2230)
@@ -113,7 +113,7 @@
        
        
 def getXMLWrapper():
-       return """<?xml version="1.0"?>
+       return """<?xml version="1.0" encoding="%s" standalone="yes"?>
 <connectiondefs xmlns="http://www.dabodev.com";
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
 xsi:schemaLocation="http://www.dabodev.com conn.xsd"
@@ -122,7 +122,7 @@
 %s
 
 </connectiondefs>
-"""
+""" % (dabo.defaultEncoding, "%s")
 
 
 def getConnTemplate():

Modified: trunk/dabo/lib/xmltodict.py
===================================================================
--- trunk/dabo/lib/xmltodict.py 2006-06-20 17:03:00 UTC (rev 2229)
+++ trunk/dabo/lib/xmltodict.py 2006-06-21 12:02:03 UTC (rev 2230)
@@ -16,7 +16,7 @@
 else:
                enc = locale.getlocale()[1]
                if enc is None:
-                       enc = "utf-8"
+                       enc = dabo.defaultEncoding
                default_encoding = enc
                
 # Python seems to need to compile code with \n linesep:

Modified: trunk/dabo/settings.py
===================================================================
--- trunk/dabo/settings.py      2006-06-20 17:03:00 UTC (rev 2229)
+++ trunk/dabo/settings.py      2006-06-21 12:02:03 UTC (rev 2230)
@@ -93,6 +93,10 @@
 # Default font size when none other is specified
 defaultFontSize = 10
 
+# Default encoding to use when none is specified
+defaultEncoding = "utf-8"
+
+
 ### Settings - end
 
 # Do not copy/paste anything below this line into settings_override.py.




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

Reply via email to