daboide Commit
Revision 643
Date: 2006-10-07 06:49:39 -0700 (Sat, 07 Oct 2006)
Author: ed
Changed:
U trunk/wizards/AppWizard/AppWizard.py
Log:
Changed the database type selection to be a dropdown list instead of a text
field.
Removed the FieldSpecs and Relations pages, as these are deprecated. I did not
remove the code for the pages, but rather just removed those pages from the
list for the wizard.
Diff:
Modified: trunk/wizards/AppWizard/AppWizard.py
===================================================================
--- trunk/wizards/AppWizard/AppWizard.py 2006-10-05 00:27:06 UTC (rev
642)
+++ trunk/wizards/AppWizard/AppWizard.py 2006-10-07 13:49:39 UTC (rev
643)
@@ -97,6 +97,9 @@
"Database" : "webtest.sqlite",
"Name" : "SQLite-default" }
+ # Save the supported dbTypes into a list
+ self.supportedDbTypes = self.dbDefaults.keys()
+
# List of all fields to create for the user to select
self.fieldNames = ("DbType", "Name", "Host", "Database",
"User",
"Password", "Port")
@@ -130,17 +133,14 @@
defaultUserProfileName=profile
# Set up the dropdown list based on the keys in the dbDefaults
dict.
- choiceParms = {"Choices": self.dbDefaults.keys(),
- "Name": "dbChoice",
- "ValueMode": "string"}
- self.dbChoice = dabo.ui.dDropdownList(self, Name="dbChoice")
- self.dbChoice.ValueMode = "string"
- self.dbChoice.Choices = self.dbDefaults.keys()
+ self.ddProfile = dabo.ui.dDropdownList(self, Name="ddProfile")
+ self.ddProfile.ValueMode = "string"
+ self.ddProfile.Choices = self.dbDefaults.keys()
if defaultUserProfileName is not None:
- self.dbChoice.Value = defaultUserProfileName
+ self.ddProfile.Value = defaultUserProfileName
else:
- self.dbChoice.Value = defaultProfileName
- self.dbChoice.bindEvent(dabo.dEvents.ValueChanged,
self.onDbChoice)
+ self.ddProfile.Value = defaultProfileName
+ self.ddProfile.bindEvent(dabo.dEvents.ValueChanged,
self.onProfileChoice)
cmd = self.addObject(dabo.ui.dButton,
Caption="New Profile...", Name="cmdNewProfile")
@@ -151,15 +151,20 @@
gs.setColExpand(True, 1)
gs.append(lbl)
hs = HSizer()
- hs.append(self.dbChoice, 1)
+ hs.append(self.ddProfile, 1)
hs.appendSpacer(8)
hs.append(cmd, 0)
gs.append(hs, "x")
+ gs.appendSpacer(20, colSpan=2)
for field in self.fieldNames:
lbl = dLabel(self, Name=("lbl%s" % field), Width=75,
Caption=("%s:" % field) )
- pw = (field.lower() == "password")
- obj = dabo.ui.dTextBox(self, PasswordEntry=pw,
Name=("txt%s" % field) )
+ if field == "DbType":
+ obj = dabo.ui.dDropdownList(self, Name=("ctl%s"
% field),
+ Choices=self.supportedDbTypes,
ValueMode="string")
+ else:
+ pw = (field.lower() == "password")
+ obj = dabo.ui.dTextBox(self, PasswordEntry=pw,
Name=("ctl%s" % field) )
obj.bindEvent(dabo.dEvents.ValueChanged,
self.onParmValueChanged)
gs.append(lbl)
@@ -176,14 +181,14 @@
else:
gs.append(obj, "x")
sz.append(gs, 1, "x")
- self.onDbChoice()
+ self.onProfileChoice()
def onDbSearch(self, evt):
"""Select a file for the database"""
pth = dabo.ui.getFile(message="Select the database")
if pth:
- self.txtDatabase.Value = pth
+ self.ctlDatabase.Value = pth
self.refresh()
@@ -192,13 +197,13 @@
object = evt.EventObject
app = object.Application
field = object.Name[3:]
- name = "appWizard.dbDefaults.%s.%s" % (self.dbChoice.Value,
field)
+ name = "appWizard.dbDefaults.%s.%s" % (self.ddProfile.Value,
field)
app.setUserSetting(name, object.Value)
- self.dbDefaults[self.dbChoice.Value][field] = object.Value
+ self.dbDefaults[self.ddProfile.Value][field] = object.Value
if field == "DbType":
# User could have changed from an embedded type to a
regular type, in
# which case more/fewer fields need to be displayed:
- self.onDbChoice()
+ self.onProfileChoice()
def onNewProfile(self, evt):
@@ -206,31 +211,34 @@
i = 1
while True:
default = "%s %s" % (base, i)
- if default in self.dbChoice.Choices:
+ if default in self.ddProfile.Choices:
i += 1
else:
break
- name = dabo.ui.getString("Please enter a name for the profile",
defaultValue=default)
+ name = dabo.ui.getString("Please enter a name for the profile",
+ defaultValue=default)
if name is not None:
+ # Defualt to the current DbType
+ currDbType = self.ctlDbType.Value
self.dbDefaults[name] = {
- "DbType" : "",
+ "DbType" : currDbType,
"Name" : "",
"Host" : "",
"Database" : "",
"User" : "",
"Password" : "",
"Port" : "" }
- dbChoice = self.dbChoice
- dbChoice.Choices = self.dbDefaults.keys()
- dbChoice.Value = name
- self.txtDbType.Value = "MySQL"
- self.txtPort.Value = "3306"
- self.txtDbType.SetFocus()
+ ddProfile = self.ddProfile
+ ddProfile.Choices = self.dbDefaults.keys()
+ ddProfile.Value = name
+ self.ctlDbType.Value = "MySQL"
+ self.ctlPort.Value = "3306"
+ self.ctlDbType.SetFocus()
- def onDbChoice(self, evt=None):
- choice = self.dbChoice.Value
+ def onProfileChoice(self, evt=None):
+ choice = self.ddProfile.Value
dbdefs = self.dbDefaults[choice]
embedded = dbdefs["DbType"] in self.embeddedDbTypes
if embedded:
@@ -240,12 +248,12 @@
for fld in self.fieldNames:
if fld in showFields:
val = dbdefs[fld]
- exec("self.txt%s.Value = r'%s' " % (fld, val) )
- exec("self.txt%s.Visible = True " % fld )
+ exec("self.ctl%s.Value = r'%s' " % (fld, val) )
+ exec("self.ctl%s.Visible = True " % fld )
else:
# Not a field used for this db type
- exec("self.txt%s.Value = None" % fld )
- exec("self.txt%s.Visible = False " % fld )
+ exec("self.ctl%s.Value = None" % fld )
+ exec("self.ctl%s.Visible = False " % fld )
# Enable the file search button if this is a file-based backend
if embedded:
self.szDB.showItem(self.btnSrch)
@@ -261,24 +269,24 @@
# Set the wizard's connect info based on the user input:
ci = self.Form.connectInfo
- dbType = self.txtDbType.Value
+ dbType = self.ctlDbType.Value
try:
ci.DbType = dbType
except ValueError:
dabo.ui.stop("The database type '%s' is
invalid. "
"Please reenter and try again."
% dbType)
- self.txtDbType.SetFocus()
+ self.ctlDbType.SetFocus()
return False
embedded = dbType in self.embeddedDbTypes
- ci.Database = self.txtDatabase.Value
- ci.Name = self.txtName.Value
+ ci.Database = self.ctlDatabase.Value
+ ci.Name = self.ctlName.Value
if not embedded:
- ci.Host = self.txtHost.Value
- ci.User = self.txtUser.Value
- ci.Password = ci.encrypt(self.txtPassword.Value)
+ ci.Host = self.ctlHost.Value
+ ci.User = self.ctlUser.Value
+ ci.Password = ci.encrypt(self.ctlPassword.Value)
try:
- ci.Port = int(self.txtPort.Value)
+ ci.Port = int(self.ctlPort.Value)
except ValueError:
ci.Port = None
# Try to get a connection::
@@ -724,9 +732,13 @@
self.outputDirectory = ""
self.connectInfo = dabo.db.dConnectInfo()
self.dbType = "MySQL" # default to MySQL
+ # Field specs are deprecated; all references will eventually
+ # be removed, but for now we need to set this reference
+ self.useFieldSpecs = False
- pgs = [PageIntro, PageDatabase, PageTableSelection,
PageUseFieldSpecs,
- PageRelations, PageTargetDirectory, PageGo]
+ # egl: 2006.10.7 - removed the field specs and relations pages.
+ pgs = [PageIntro, PageDatabase, PageTableSelection,
+ PageTargetDirectory, PageGo]
self.append(pgs)
self.layout()
self.Centered = True
_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-dev