def openFile(self, connFile=None): # See if the user wants to save changes (if any) if not self.confirmChanges(): return self.connFile = connFile # Read in the connection def file if self.connFile: # Make sure that the passed file exists! if not os.path.exists(self.connFile): dabo.log.error(_("The connection file '%s' does not exist.") % self.connFile) self.connFile = None if self.connFile is None: f = dui.getFile(self.fileExtension, message=_("Select a file..."), defaultPath=os.getcwd() ) if f is not None: self.connFile = f if self.connFile is not None: self.connFile = ustr(self.connFile) # Read the XML into a local dictionary self.connDict = importConnections(self.connFile) # Save a copy for comparison self._origConnDict = copy.deepcopy(self.connDict) # Populate the connection names self.connectionSelector.Choices = list(self.connDict.keys()) # Set the current connection self.currentConn = list(self.connDict.keys())[0] # Set the form caption self.Caption = _("Dabo Connection Editor: %s") % os.path.basename(self.connFile) # Fill the controls self._opening = True self.populate() self._opening = False # Show/hide controls as needed self.enableControls() self.layout() return True else: return False
def openFile(self, connFile=None): # See if the user wants to save changes (if any) if not self.confirmChanges(): return self.connFile = connFile # Read in the connection def file if self.connFile: # Make sure that the passed file exists! if not os.path.exists(self.connFile): dabo.log.error(_("The connection file '%s' does not exist.") % self.connFile) self.connFile = None if self.connFile is None: f = dui.getFile(self.fileExtension, message=_("Select a file..."), defaultPath=os.getcwd() ) if f is not None: self.connFile = f if self.connFile is not None: self.connFile = ustr(self.connFile) # Read the XML into a local dictionary self.connDict = importConnections(self.connFile) # Save a copy for comparison self._origConnDict = copy.deepcopy(self.connDict) # Populate the connection names self.connectionSelector.Choices = self.connDict.keys() # Set the current connection self.currentConn = self.connDict.keys()[0] # Set the form caption self.Caption = _("Dabo Connection Editor: %s") % os.path.basename(self.connFile) # Fill the controls self._opening = True self.populate() self._opening = False # Show/hide controls as needed self.enableControls() self.layout() return True else: return False
def onDbSelect(self, evt): dbFile = dui.getFile() if dbFile: self.database = dbFile self.update()