class ConnectionManager:
	def __init__(self,host,port):
		self.proxy = SkoleSYS_Client(host,port)
		
	def _get_proxy_handle(self):
		counter = 0
		# Check if it is nessecary to request a new session id
		# the SOAP server may have flushed the session info
		if not self.proxy.test_session_id():
			self.proxy._get_id()
			
		while not self.proxy.test_binded() and counter<3:
				
			username,passwd = loginwdg.get_credentials()
			if username==None:
				# Login was cancelled
				sys.exit(0)
			bindres = self.proxy.bind(username,passwd)
			if type(bindres) == bool and bindres==True:	
				self.binded_user = username
				break

			if type(bindres) == int and bindres==-9999:
				# Acess denied
				accesstools.access_denied_dialog('access.soap.bind')
				sys.exit(0)
			counter+=1
		if counter>=3:
			print "The connection manager has cut this session from further use"
			sys.exit(0)
		return self.proxy
class ConnectionManager:
	def __init__(self,host,port):
		self.proxy = SkoleSYS_Client(host,port)
		
	def get_proxy_handle(self):
		counter = 0
		while not self.proxy.test_binded() and counter<3:
			passwd = QInputDialog.getText(qApp.translate("General","SkoleSYS Administration"), qApp.translate("General","Enter administrator password"), QLineEdit.Password)
			if passwd[1]==False:
				sys.exit(0)
			if self.proxy.bind(str(passwd[0].utf8())):
				break
			counter+=1
		if counter>=3:
			print "The connection manager has cut this session from further use"
			sys.exit(0)
		return self.proxy
			elif value.type() == QtCore.QVariant.String:
				value = str(value.toString().toUtf8()).strip()
				if not self.option_info.has_key(option_name) and value == '':
					self.change_info.pop(option_name)
					#proxy.unset_groupservice_option(self.servicename,self.groupname,option_name)
				else:
					#proxy.set_groupservice_option_value(self.servicename,self.groupname,option_name,value)
					self.change_info[option_name] = value

			elif value.type() == QtCore.QVariant.Bool:
				value = str(value.toBool())
				#proxy.set_groupservice_option_value(self.servicename,self.groupname,option_name,value)
				self.change_info[option_name] = value


if __name__ == '__main__':

	from skolesys.soap.client import SkoleSYS_Client
	cli = SkoleSYS_Client('https://127.0.0.1',10033)
	options = cli.list_groupservice_option_available('servgrp1','webservice')
	print options
	
	app = QtGui.QApplication(sys.argv)
	ui = OptionsTableView(None)
	ui.setOptions(options)
	ui.cli = cli
	model = ui.model()

	ui.show()
	sys.exit(app.exec_())
        self.loadGroupData()
        self.btn_apply.setEnabled(False)

    def closeEvent(self, ce):
        if not self.force_close_without_save and self.isDirty():
            res = QtGui.QMessageBox.question(
                None,
                self.tr("Close"),
                self.tr("Changes have been made, do you wish to close without saving?"),
                0x00800000,
                0x00010000,
            )
            if res == 0x00010000:
                ce.setAccepted(False)


if __name__ == "__main__":
    import sys

    app = QtGui.QApplication(sys.argv)
    ui = GroupEditWdg(None, None)

    from skolesys.soap.client import SkoleSYS_Client

    cli = SkoleSYS_Client("https://mainserver.localnet", 10033)
    options = cli.list_groupservice_options_available("servgrp1", "webservice")
    ui.tbl_serviceoptions.setOptions(options)
    ui.tbl_serviceoptions.cli = cli
    ui.show()
    sys.exit(app.exec_())
	def __init__(self,host,port):
		self.proxy = SkoleSYS_Client(host,port)