dabo Commit
Revision 4936
Date: 2009-01-17 17:24:06 -0800 (Sat, 17 Jan 2009)
Author: Ed
Trac: http://trac.dabodev.com/changeset/4936
Changed:
U trunk/ide/ClassDesigner.py
U trunk/ide/ClassDesignerEditor.py
U trunk/ide/ClassDesignerFormMixin.py
U trunk/ide/wizards/QuickLayoutWizard.py
Log:
Adopted the standard that all Class Designer files will be written/read with
utf-8 encoding.
Fixed a problem in which a newline was added to code, which didn't affect
execution, but dirtied the buffer when nothing had actually changed.
Updated the QuickLayoutWizard to recognize web-based connections and notify the
user that they cannot use that wizard with remote connections.
Diff:
Modified: trunk/ide/ClassDesigner.py
===================================================================
--- trunk/ide/ClassDesigner.py 2009-01-18 01:15:43 UTC (rev 4935)
+++ trunk/ide/ClassDesigner.py 2009-01-18 01:24:06 UTC (rev 4936)
@@ -1809,7 +1809,7 @@
code = tmpl % fname
out = os.path.splitext(nm)[0] + ".py"
try:
- open(out, "w").write(code)
+ codecs.open(out, "w", encoding="utf-8").write(code)
dui.info(_("You can run your form by running the
file\n%s")
% out, title=_("Runnable App Saved"))
except IOError, e:
Modified: trunk/ide/ClassDesignerEditor.py
===================================================================
--- trunk/ide/ClassDesignerEditor.py 2009-01-18 01:15:43 UTC (rev 4935)
+++ trunk/ide/ClassDesignerEditor.py 2009-01-18 01:24:06 UTC (rev 4936)
@@ -321,6 +321,8 @@
if nonEvent is None:
nonEvent = mthd not in
self.Controller.getClassEvents(obj._baseClass)
txt = self._getMethodBase(mthd, not (nonEvent is True))
+ if isinstance(txt, str):
+ txt = txt.decode(ed.Encoding)
if ed.Value != txt:
ed.Value = txt
ed._clearDocument(clearText=False)
@@ -597,7 +599,7 @@
# txt = ""
if objCode:
txt = self._extractImports(txt)
- objCode[mthd] = txt.rstrip() + "\n"
+ objCode[mthd] = txt
else:
rep[obj] = {}
rep[obj][mthd] = txt
Modified: trunk/ide/ClassDesignerFormMixin.py
===================================================================
--- trunk/ide/ClassDesignerFormMixin.py 2009-01-18 01:15:43 UTC (rev 4935)
+++ trunk/ide/ClassDesignerFormMixin.py 2009-01-18 01:24:06 UTC (rev 4936)
@@ -4,6 +4,7 @@
import time
import random
import new
+import codecs
import dabo
from dabo.dLocalize import _
import dabo.dEvents as dEvents
@@ -490,7 +491,7 @@
xml = xtd.dicttoxml(propDict)
# Try opening the file. If it is read-only, it will raise an
# IOErrorrror that the calling method can catch.
- open(fname, "wb").write(xml)
+ codecs.open(fname, "wb", encoding="utf-8").write(xml)
cfName = "%s-code.py" % os.path.splitext(fname)[0]
if singleFile:
# Delete the code file if present.
@@ -498,7 +499,8 @@
os.remove(cfName)
else:
# Write out the code file
- open(cfName,
"wb").write(self._createDesignerCode(codeDict))
+ desCode = self._createDesignerCode(codeDict)
+ codecs.open(cfName, "w",
encoding="utf-8").write(desCode)
if currForm:
currForm.bringToFront()
self.saveState()
@@ -587,7 +589,7 @@
xml = xtd.dicttoxml(propDict)
# Try opening the file. If it is read-only, it will raise an
# IOError that the calling method can catch.
- open(clsFile, "wb").write(xml)
+ codecs.open(clsFile, "wb", encoding="utf-8").write(xml)
def getClass(self):
@@ -754,7 +756,7 @@
except IndexError:
nxtClsLn = -1
# Read in the file, and extract this class's code.
- f = open(inf.file)
+ f = codecs.open(inf.file, "r", encoding="utf-8")
txt = []
for i in range(thisClsLn-1):
f.readline()
@@ -836,9 +838,9 @@
self.Application.copyToClipboard(bizcode)
else:
fname = "%(tblTitle)sBizobj.py" % locals()
- file(os.path.join(bizdir, fname), "w").write(bizcode)
+ codecs.open(os.path.join(bizdir, fname), "w",
encoding="utf-8").write(bizcode)
clsname = fname.strip(".py")
- file(os.path.join(bizdir, "__init__.py"),
"a").write("\nfrom %(clsname)s import %(clsname)s\n" % locals())
+ codecs.open(os.path.join(bizdir, "__init__.py"), "a",
encoding="utf-8").write("\nfrom %(clsname)s import %(clsname)s\n" % locals())
# Now create the import code for the form.
loadcode = loadCodeTemplate % locals()
Modified: trunk/ide/wizards/QuickLayoutWizard.py
===================================================================
--- trunk/ide/wizards/QuickLayoutWizard.py 2009-01-18 01:15:43 UTC (rev
4935)
+++ trunk/ide/wizards/QuickLayoutWizard.py 2009-01-18 01:24:06 UTC (rev
4936)
@@ -757,12 +757,15 @@
def start(self):
pgs = [PgConnectionSelect, PgSelect, PgOrdering, PgLayout,
PgSample, PgBiz]
- cxn = False
+ cxn = None
if self.ConnectionName:
cxn = self.makeConnection(showAlert=False)
if cxn:
# We don't need the connection selector page
pgs.pop(0)
+ elif cxn is False:
+ # Error; do not proceed.
+ return False
self.append(pgs)
super(QuickLayoutWizard, self).start()
@@ -770,8 +773,11 @@
def makeConnection(self, showAlert=True):
if self.ConnectionFile:
self.Application.addConnectFile(self.ConnectionFile)
+ conn = self.Application.getConnectionByName(self.ConnectionName)
+ if conn.ConnectInfo.DbType == "web":
+ dabo.ui.stop(_("Sorry, you cannot use web connections
with this wizard."))
+ return False
try:
- conn =
self.Application.getConnectionByName(self.ConnectionName)
crs = conn.getDaboCursor()
self.ConnectionFile =
self.Application.dbConnectionNameToFiles[self.ConnectionName]
except StandardError, e:
@@ -779,7 +785,6 @@
dabo.ui.stop(_("Could not make connection to
'%s'") %
self.ConnectionName)
return False
-
tbls = crs.getTables()
for tb in tbls:
fldDict = {}
_______________________________________________
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]