daboide Commit
Revision 838
Date: 2007-04-24 11:42:05 -0700 (Tue, 24 Apr 2007)
Author: Ed
Trac: http://svn.dabodev.com/trac/daboide/changeset/838
Changed:
U trunk/CxnEditor.py
Log:
Fixed a lot of the pathing issues. Paths are now stored relative to the cnxml
file, but are maintained as absolute paths inside of the editor itself.
Fixed a problem with unmodified empty connections being recognized as having
been changed.
Improved handling of control visibility when switching between file- and
server-based databases.
Diff:
Modified: trunk/CxnEditor.py
===================================================================
--- trunk/CxnEditor.py 2007-04-23 15:53:32 UTC (rev 837)
+++ trunk/CxnEditor.py 2007-04-24 18:42:05 UTC (rev 838)
@@ -9,8 +9,9 @@
import dabo.dEvents as dEvents
import dabo.dConstants as k
from dabo.dLocalize import _
-from dabo.lib.connParser import createXML, importConnections
-
+from dabo.lib.connParser import createXML
+from dabo.lib.connParser import importConnections
+import dabo.lib.utils as utils
dui.loadUI("wx")
@@ -49,11 +50,6 @@
self.openFile()
- def openFile(self):
- self.activeControlValid()
- self.openFile()
-
-
def createControls(self):
self.Caption = "Connection Editor"
self.Size= (500, 800)
@@ -202,23 +198,7 @@
def onHit_btnTest(self, evt):
- # Update the values
- self.updtFromForm()
- # Create a connection object.
- ci =
dabo.db.dConnectInfo(connInfo=self.connDict[self.currentConn])
- try:
- conn = ci.getConnection()
- conn.close()
- except:
- conn = None
-
- if conn:
- msg = _("The connection was successful!")
- mb = dui.info
- else:
- msg = _("Unable to make connection")
- mb = dui.stop
- mb(message=msg, title="Connection Test")
+ self.testConnection()
def onHit_btnOpen(self, evt):
@@ -248,7 +228,7 @@
self.saveFile()
- def onHit_DbType(self, evt):
+ def onValueChanged_DbType(self, evt):
# Update the values
self.updtFromForm()
self.enableControls()
@@ -285,9 +265,29 @@
self.update()
+ def testConnection(self):
+ # Update the values
+ self.updtFromForm()
+ # Create a connection object.
+ ci =
dabo.db.dConnectInfo(connInfo=self.connDict[self.currentConn])
+ try:
+ conn = ci.getConnection()
+ conn.close()
+ except:
+ conn = None
+
+ if conn:
+ msg = _("The connection was successful!")
+ mb = dui.info
+ else:
+ msg = _("Unable to make connection")
+ mb = dui.stop
+ mb(message=msg, title="Connection Test")
+
+
def updtFromForm(self):
""" Grab the current values from the form, and update
- the conneciton dictionary with them.
+ the connection dictionary with them.
"""
# Make sure that changes to the current control are used.
self.activeControlValid()
@@ -308,12 +308,13 @@
def updtToForm(self):
- """ Populate the current values from the conneciton
+ """ Populate the current values from the connection
dictionary.
"""
if self.currentConn is not None:
dd = self.connDict[self.currentConn]
for fld in dd.keys():
+ val = dd[fld]
if fld == "password":
val = self.crypt.decrypt(dd[fld])
else:
@@ -346,13 +347,15 @@
# Update the values
self.updtFromForm()
newName = "Connection " + str(len(self.connDict.keys()) + 1)
- self.connDict[newName] = {"dbtype" : u"MySQL",
+ self.connDict[newName] = {
+ "dbtype" : u"MySQL",
"name" : "",
"host" : "",
"database" : "",
"user" : "",
"password" : "",
- "port" : "3306" }
+ "port" : 3306
+ }
self.currentConn = newName
self.connectionSelector.Choices = self.connDict.keys()
self.populate()
@@ -397,6 +400,7 @@
def openFile(self, connFile=None):
+ self.activeControlValid()
# See if the user wants to save changes (if any)
if not self.confirmChanges():
return
@@ -428,7 +432,7 @@
self.Caption = _("Dabo Connection Editor: %s") %
os.path.basename(self.connFile)
# Fill the controls
self.populate()
- self.Layout()
+ self.layout()
return True
else:
return False
@@ -448,7 +452,6 @@
def writeChanges(self):
- xml = createXML(self.connDict.values() )
if self.connFile == self.newFileName:
# Ask for a file name
pth = dui.getSaveAs(message="Save File As...",
@@ -463,10 +466,23 @@
pth += "."
pth += self.fileExtension
self.connFile = pth
+ # Get the values from the connDict, and adjust any pathing
+ # to be relative
+ vals = self.relPaths(self.connDict.values())
+ xml = createXML(vals)
open(self.connFile, "w").write(xml)
dabo.ui.callAfter(self.bringToFront)
+ def relPaths(self, vals):
+ for val in vals:
+ db = val["database"]
+ if os.path.exists(db):
+ val["database"] = utils.relativePath(db,
self.connFile)
+ return vals
+
+
+
def main():
files = sys.argv[1:]
app = dabo.dApp()
_______________________________________________
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/dabo-dev/[EMAIL PROTECTED]