dabo Commit
Revision 5915
Date: 2010-07-10 07:43:39 -0700 (Sat, 10 Jul 2010)
Author: Ed
Trac: http://trac.dabodev.com/changeset/5915
Changed:
U trunk/dabo/biz/dBizobj.py
U trunk/dabo/dBug.py
U trunk/dabo/dLocalize.py
U trunk/dabo/lib/DesignerClassConverter.py
U trunk/dabo/lib/EasyDialogBuilder.py
U trunk/dabo/lib/RemoteConnector.py
U trunk/dabo/lib/__init__.py
U trunk/dabo/lib/datanav/Form.py
U trunk/dabo/lib/datanav/Page.py
U trunk/dabo/lib/dates.py
U trunk/dabo/lib/eventMixin.py
U trunk/dabo/lib/logger.py
U trunk/dabo/lib/reportWriter.py
U trunk/dabo/lib/reporting_stefano/serialization/attributes.py
U trunk/dabo/lib/test/test_dates.py
U trunk/dabo/lib/uuid.py
U trunk/dabo/lib/xmltodict.py
Log:
Converted more of the codebase from str() to ustr().
Diff:
Modified: trunk/dabo/biz/dBizobj.py
===================================================================
--- trunk/dabo/biz/dBizobj.py 2010-07-10 14:32:03 UTC (rev 5914)
+++ trunk/dabo/biz/dBizobj.py 2010-07-10 14:43:39 UTC (rev 5915)
@@ -7,6 +7,7 @@
import dabo.dConstants as kons
from dabo.db.dCursorMixin import dCursorMixin
from dabo.dLocalize import _
+from dabo.lib.utils import ustr
import dabo.dException as dException
from dabo.dObject import dObject
from dabo.lib.RemoteConnector import RemoteConnector
@@ -1274,8 +1275,8 @@
row = self.seek(pk, self.KeyField, caseSensitive=True,
near=False,
runRequery=True)
if row == -1:
- # Need to use str(pk) because pk might be a tuple.
- raise dabo.dException.RowNotFoundException, _("PK Value
'%s' not found in the dataset") % str(pk)
+ # Need to use ustr(pk) because pk might be a tuple.
+ raise dabo.dException.RowNotFoundException, _("PK Value
'%s' not found in the dataset") % ustr(pk)
def hasPK(self, pk):
Modified: trunk/dabo/dBug.py
===================================================================
--- trunk/dabo/dBug.py 2010-07-10 14:32:03 UTC (rev 5914)
+++ trunk/dabo/dBug.py 2010-07-10 14:43:39 UTC (rev 5915)
@@ -5,6 +5,7 @@
import inspect
from cStringIO import StringIO
import dabo
+from dabo.lib.utils import ustr
def logPoint(msg="", levels=None):
@@ -17,7 +18,7 @@
stack.reverse()
output = StringIO()
if msg:
- output.write(str(msg) + "\n")
+ output.write(ustr(msg) + "\n")
stackSection = stack[-1*levels:]
for stackLine in stackSection:
Modified: trunk/dabo/dLocalize.py
===================================================================
--- trunk/dabo/dLocalize.py 2010-07-10 14:32:03 UTC (rev 5914)
+++ trunk/dabo/dLocalize.py 2010-07-10 14:43:39 UTC (rev 5915)
@@ -6,6 +6,7 @@
import gettext
import warnings
import dabo
+from dabo.lib.utils import ustr
_defaultLanguage, _defaultEncoding = locale.getdefaultlocale()
@@ -85,7 +86,7 @@
No translation file found for domain 'dabo'.
Locale dir = %s
Languages = %s
- Codeset = %s """ % (daboLocaleDir, str(lang), charset))
+ Codeset = %s """ % (daboLocaleDir, ustr(lang), charset))
for domain, localedir in _domains.items():
if domain == "dabo":
@@ -98,7 +99,7 @@
No translation file found for domain '%s'.
Locale dir = %s
Languages = %s
- Codeset = %s """ % (domain, daboLocaleDir, str(lang), charset))
+ Codeset = %s """ % (domain, daboLocaleDir, ustr(lang), charset))
if daboTranslation:
translation.add_fallback(daboTranslation)
_currentTrans = translation.ugettext
Modified: trunk/dabo/lib/DesignerClassConverter.py
===================================================================
--- trunk/dabo/lib/DesignerClassConverter.py 2010-07-10 14:32:03 UTC (rev
5914)
+++ trunk/dabo/lib/DesignerClassConverter.py 2010-07-10 14:43:39 UTC (rev
5915)
@@ -20,6 +20,7 @@
import dabo.ui.dialogs as dlgs
import dabo.lib.xmltodict as xtd
import dabo.lib.DesignerUtils as desUtil
+from dabo.lib.utils import ustr
# Doesn't matter what platform we're on; Python needs
# newlines in its compiled code.
LINESEP = "\n"
@@ -883,6 +884,7 @@
self._clsHdrText = """import dabo
dabo.ui.loadUI("wx")
import dabo.dEvents as dEvents
+from dabo.lib.utils import ustr
import sys
|classImportStatements|
@@ -1054,7 +1056,7 @@
def getControlClass(base):
# Create a pref key that is the Designer key plus the name of the
control
- prefkey = str(base).split(".")[-1].split("'")[0]
+ prefkey = ustr(base).split(".")[-1].split("'")[0]
class controlMix(cmix, base):
superControl = base
superMixin = cmix
@@ -1063,7 +1065,7 @@
apply(base.__init__,(self,) + args, kwargs)
parent = self._extractKey(kwargs, "parent")
cmix.__init__(self, parent, **kwargs)
- self.NameBase =
str(self._baseClass).split(".")[-1].split("'")[0]
+ self.NameBase =
ustr(self._baseClass).split(".")[-1].split("'")[0]
self.BasePrefKey = prefkey
return controlMix
Modified: trunk/dabo/lib/EasyDialogBuilder.py
===================================================================
--- trunk/dabo/lib/EasyDialogBuilder.py 2010-07-10 14:32:03 UTC (rev 5914)
+++ trunk/dabo/lib/EasyDialogBuilder.py 2010-07-10 14:43:39 UTC (rev 5915)
@@ -13,8 +13,10 @@
import types
import dabo.dEvents as dEvents
+from dabo.lib.utils import ustr
+
class EasyDialogBuilder(object):
def makePageFrame(self, parent, pageData, properties=None):
"""makePageFrame(parent, pageData, properties=None) ->
dabo.ui.dPageFrame
@@ -30,7 +32,7 @@
for page in pageData:
if page.get("image"):
- page["imgKey"]=str(pageFrame.PageCount)
+ page["imgKey"] = ustr(pageFrame.PageCount)
pageFrame.addImage(page["image"],
imgKey=page["imgKey"])
elif not page.get("caption"):
caption = "Page%i" % (pageFrame.PageCount,)
Modified: trunk/dabo/lib/RemoteConnector.py
===================================================================
--- trunk/dabo/lib/RemoteConnector.py 2010-07-10 14:32:03 UTC (rev 5914)
+++ trunk/dabo/lib/RemoteConnector.py 2010-07-10 14:43:39 UTC (rev 5915)
@@ -15,6 +15,7 @@
import dabo.dException as dException
from dabo.dObject import dObject
from dabo.dLocalize import _
+from dabo.lib.utils import ustr
from dabo.lib.manifest import Manifest
jsonEncode = dabo.lib.jsonEncode
jsonDecode = dabo.lib.jsonDecode
@@ -96,7 +97,7 @@
# Get rid of as much unnecessary formatting as possible.
sql = re.sub(r"\n *", " ", sql)
sql = re.sub(r" += +", " = ", sql)
- sqlparams = str(biz.getParams())
+ sqlparams = ustr(biz.getParams())
params = {"SQL": sql, "SQLParams": sqlparams, "KeyField":
biz.KeyField, "_method": "GET"}
prm = urllib.urlencode(params)
try:
@@ -283,7 +284,7 @@
# A zero filecode represents no changed files
if filecode:
# Request the files
- url = self._getManifestUrl(appname, "files",
str(filecode))
+ url = self._getManifestUrl(appname, "files",
ustr(filecode))
try:
res = self.UrlOpener.open(url)
except urllib2.HTTPError, e:
Modified: trunk/dabo/lib/__init__.py
===================================================================
--- trunk/dabo/lib/__init__.py 2010-07-10 14:32:03 UTC (rev 5914)
+++ trunk/dabo/lib/__init__.py 2010-07-10 14:43:39 UTC (rev 5915)
@@ -9,14 +9,15 @@
import uuid
import dabo
+from dabo.lib.utils import ustr
def getRandomUUID():
- return str(uuid.uuid4())
+ return ustr(uuid.uuid4())
def getMachineUUID():
- return str(uuid.uuid1())
+ return ustr(uuid.uuid1())
try:
Modified: trunk/dabo/lib/datanav/Form.py
===================================================================
--- trunk/dabo/lib/datanav/Form.py 2010-07-10 14:32:03 UTC (rev 5914)
+++ trunk/dabo/lib/datanav/Form.py 2010-07-10 14:43:39 UTC (rev 5915)
@@ -16,6 +16,7 @@
import dabo.lib.reportWriter as lrw
except ImportError, e:
_has_reporting_libs = False
+from dabo.lib.utils import ustr
dabo.ui.loadUI("wx")
@@ -330,7 +331,7 @@
self.PageFrame.Pages[1].BrowseGrid.refresh()
except AttributeError, e:
# Grid may not even exist yet.
- if "BrowseGrid" in str(e):
+ if "BrowseGrid" in ustr(e):
pass
else:
raise
@@ -579,14 +580,14 @@
rw.write()
except (UnicodeDecodeError,), e:
#error_string = traceback.format_exc()
- error_string = str(e)
+ error_string = ustr(e)
row_number = rw.RecordNumber
dabo.ui.stop("There was a problem having to do
with the Unicode encoding "
"of your table, and ReportLab's
inability to deal with any encoding "
"other than UTF-8. Sorry, but
currently we don't have a resolution to "
"the problem, other than to
recommend that you convert your data to "
"UTF-8 encoding. Here's the
exact error message received:\n\n%s"
- "\n\nThis occurred in Record %s
of your cursor." % (str(e), row_number))
+ "\n\nThis occurred in Record %s
of your cursor." % (ustr(e), row_number))
return
# Now, preview using the platform's default pdf viewer:
Modified: trunk/dabo/lib/datanav/Page.py
===================================================================
--- trunk/dabo/lib/datanav/Page.py 2010-07-10 14:32:03 UTC (rev 5914)
+++ trunk/dabo/lib/datanav/Page.py 2010-07-10 14:43:39 UTC (rev 5915)
@@ -6,6 +6,7 @@
import dabo.dEvents as dEvents
from dabo.dLocalize import _, n_
from dabo.dObject import dObject
+from dabo.lib.utils import ustr
from dabo.ui import dPanel
import Grid
@@ -301,8 +302,8 @@
elif fldType in ("date", "datetime"):
if isinstance(ctrl,
dabo.ui.dDateTextBox):
dtTuple = ctrl.getDateTuple()
- dt = "%s-%s-%s" % (dtTuple[0],
str(dtTuple[1]).zfill(2),
-
str(dtTuple[2]).zfill(2) )
+ dt = "%s-%s-%s" % (dtTuple[0],
ustr(dtTuple[1]).zfill(2),
+
ustr(dtTuple[2]).zfill(2) )
else:
dt = matchVal
matchStr = biz.formatDateTime(dt)
Modified: trunk/dabo/lib/dates.py
===================================================================
--- trunk/dabo/lib/dates.py 2010-07-10 14:32:03 UTC (rev 5914)
+++ trunk/dabo/lib/dates.py 2010-07-10 14:43:39 UTC (rev 5915)
@@ -7,6 +7,7 @@
import re
import time
import dabo
+from dabo.lib.utils import ustr
_dregex = {}
_dtregex = {}
@@ -138,7 +139,7 @@
if not groups.has_key("year"):
curYear = datetime.date.today().year
if groups.has_key("shortyear"):
- groups["year"] = int("%s%s" %
(str(curYear)[:2],
+ groups["year"] = int("%s%s" %
(ustr(curYear)[:2],
groups["shortyear"]))
else:
groups["year"] = curYear
@@ -196,7 +197,7 @@
if not groups.has_key("year"):
curYear = datetime.date.today().year
if groups.has_key("shortyear"):
- groups["year"] = int("%s%s" %
(str(curYear)[:2],
+ groups["year"] = int("%s%s" %
(ustr(curYear)[:2],
groups["shortyear"]))
else:
groups["year"] = curYear
Modified: trunk/dabo/lib/eventMixin.py
===================================================================
--- trunk/dabo/lib/eventMixin.py 2010-07-10 14:32:03 UTC (rev 5914)
+++ trunk/dabo/lib/eventMixin.py 2010-07-10 14:43:39 UTC (rev 5915)
@@ -6,6 +6,7 @@
from dabo.dLocalize import _
+
class EventMixin(object):
"""Mix-in class making objects know how to bind and raise Dabo events.
@@ -63,8 +64,6 @@
if eventSig in self.__raisedEvents:
# The event has already been called, for reasons we
don't understand.
# Just return and do nothing.
- #dabo.errorLog.write("End-around call of event %s" %
str(eventSig))
- #traceback.print_stack()
return None
else:
self.__raisedEvents.append(eventSig)
Modified: trunk/dabo/lib/logger.py
===================================================================
--- trunk/dabo/lib/logger.py 2010-07-10 14:32:03 UTC (rev 5914)
+++ trunk/dabo/lib/logger.py 2010-07-10 14:43:39 UTC (rev 5915)
@@ -2,7 +2,10 @@
import sys, os, time
from dabo.dObject import dObject
from dabo.dLocalize import _
+from dabo.lib.utils import ustr
+
+
class Log(dObject):
""" Generic logger object for Dabo.
@@ -64,7 +67,7 @@
return ""
def _setCaption(self, val):
- self._caption = str(val)
+ self._caption = ustr(val)
def _getLogObject(self):
Modified: trunk/dabo/lib/reportWriter.py
===================================================================
--- trunk/dabo/lib/reportWriter.py 2010-07-10 14:32:03 UTC (rev 5914)
+++ trunk/dabo/lib/reportWriter.py 2010-07-10 14:43:39 UTC (rev 5915)
@@ -53,6 +53,7 @@
from dabo.dLocalize import _
from dabo.lib.caselessDict import CaselessDict
from reportlab.lib.utils import ImageReader
+from dabo.lib.utils import ustr
import Image as PILImage
import reportUtils
@@ -259,7 +260,7 @@
return self.AvailableProps[propName]["doc"]
def updatePropVal(self, propName, propVal):
- self.setProp(str(propName), str(propVal))
+ self.setProp(ustr(propName), ustr(propVal))
def _getAvailableProps(self):
@@ -1691,7 +1692,7 @@
self._pageCount = pageCount
page_count_objects = self.page_count_objects.get(pageNum, [])
for x, y, obj, expr in page_count_objects:
- obj["expr_pagecount"] = expr.replace("^^^PageCount^^^",
str(self.PageCount))
+ obj["expr_pagecount"] = expr.replace("^^^PageCount^^^",
ustr(self.PageCount))
self.draw(obj, (x,y))
del obj["expr_pagecount"]
@@ -2255,7 +2256,7 @@
import time, md5, random
t1 = time.time()
t2 = t1 + random.random()
- base = md5.new(str(t1 +t2))
+ base = md5.new(ustr(t1 +t2))
name = "_" + base.hexdigest()
return name
Modified: trunk/dabo/lib/reporting_stefano/serialization/attributes.py
===================================================================
--- trunk/dabo/lib/reporting_stefano/serialization/attributes.py
2010-07-10 14:32:03 UTC (rev 5914)
+++ trunk/dabo/lib/reporting_stefano/serialization/attributes.py
2010-07-10 14:43:39 UTC (rev 5915)
@@ -3,6 +3,8 @@
# if serialization lib is specific to reporting, it should be moved
# to dabo.lib.reporting.serialization. Stefano, thoughts?
from reportlab.lib import pagesizes
+import dabo
+from dabo.lib.utils import ustr
class SerializableAttribute(object):
@@ -69,8 +71,8 @@
class PagesizesAttr(SerializableAttribute):
def evaluate(self, value, env):
- pageSize = getattr(pagesizes, str(value).upper(), None)
+ pageSize = getattr(pagesizes, ustr(value).upper(), None)
if pageSize is None:
- pageSize = getattr(pagesizes,
str(self.default).upper(), None)
+ pageSize = getattr(pagesizes,
ustr(self.default).upper(), None)
return pageSize
Modified: trunk/dabo/lib/test/test_dates.py
===================================================================
--- trunk/dabo/lib/test/test_dates.py 2010-07-10 14:32:03 UTC (rev 5914)
+++ trunk/dabo/lib/test/test_dates.py 2010-07-10 14:43:39 UTC (rev 5915)
@@ -3,9 +3,10 @@
import datetime
import dabo
from dabo.lib import dates
+from dabo.lib.utils import ustr
year = datetime.date.today().year
-year_str4 = str(year)
+year_str4 = ustr(year)
year_str2 = year_str4[-2:]
class Test_Dates(unittest.TestCase):
Modified: trunk/dabo/lib/uuid.py
===================================================================
--- trunk/dabo/lib/uuid.py 2010-07-10 14:32:03 UTC (rev 5914)
+++ trunk/dabo/lib/uuid.py 2010-07-10 14:43:39 UTC (rev 5915)
@@ -46,6 +46,9 @@
This module works with Python 2.3 or higher."""
+from dabo.lib.utils import ustr
+
+
__author__ = 'Ka-Ping Yee <[email protected]>'
__date__ = '$Date: 2006/06/12 23:15:40 $'.split()[1].replace('/', '-')
__version__ = '$Revision: 1.30 $'.split()[1]
@@ -178,7 +181,7 @@
return self.int
def __repr__(self):
- return 'UUID(%r)' % str(self)
+ return 'UUID(%r)' % ustr(self)
def __setattr__(self, name, value):
raise TypeError('UUID objects are immutable')
@@ -250,7 +253,7 @@
hex = property(get_hex)
def get_urn(self):
- return 'urn:uuid:' + str(self)
+ return 'urn:uuid:' + ustr(self)
urn = property(get_urn)
Modified: trunk/dabo/lib/xmltodict.py
===================================================================
--- trunk/dabo/lib/xmltodict.py 2010-07-10 14:32:03 UTC (rev 5914)
+++ trunk/dabo/lib/xmltodict.py 2010-07-10 14:43:39 UTC (rev 5915)
@@ -15,6 +15,8 @@
import dabo.lib.DesignerUtils as desUtil
from dabo.dLocalize import _
from dabo.lib.utils import resolvePath
+from dabo.lib.utils import ustr
+
app = dabo.dAppRef
if app:
default_encoding = app.Encoding
@@ -36,6 +38,7 @@
eol = os.linesep
+
class Xml2Obj(object):
"""XML to Object"""
def __init__(self, encoding=None):
@@ -225,7 +228,7 @@
any illegal XML characters.
"""
if not isinstance(val, basestring):
- val = str(val)
+ val = ustr(val)
if not isinstance(val, unicode):
val = unicode(val, default_encoding)
if noQuote:
_______________________________________________
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]