Exemplo n.º 1
0
	def setConnectionParams(self, cxnfile=None, dbType=None, database=None,
			host=None, user=None, password=None, plainTextPassword=None):
		if cxnfile:
			cxDict = importConnections(cxnfile)
			self.setConnection(list(cxDict.values())[0])
		else:
			cxnDict = {"DbType": dbType, "Database": database}
			if host:
				cxnDict["Host"]  = host
			if user:
				cxnDict["User"] = user
			if plainTextPassword:
				cxnDict["PlainTextPassword"] = plainTextPassword
			if password:
				cxnDict["Password"] = password
			ci = dabo.db.dConnectInfo(cxnDict)
			cn = dabo.db.dConnection(ci)
			self.setConnection(cn)
Exemplo n.º 2
0
	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
Exemplo n.º 3
0
	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