def loadServerMeta(self, serverName): serverName = unicode(serverName) if not (serverName in self.preloadedServerMeta.keys()): serverMeta = self._serverList.getServerObject(serverName) self.preloadedServerMeta[serverName] = ObjectClassAttributeInfo( serverMeta) return self.preloadedServerMeta[serverName]
def addAttribute(self): """ Add attributes to the current object. """ dialog = AddAttributeWizard(self) dialog.setData(self.smartObjectCopy(self.entryModel.getSmartObject())) dialog.exec_() if dialog.result() == QDialog.Rejected: return attribute = str(dialog.attributeBox.currentText()) showAll = dialog.enableAllBox.isChecked() if dialog.binaryBox.isChecked(): attributeSet = set([attribute + ";binary"]) else: attributeSet = set([attribute]) if showAll and not (attribute.lower() in dialog.possibleAttributes): objectClass = str(dialog.classBox.currentItem().text()) self.entryModel.addObjectClass(objectClass) serverSchema = ObjectClassAttributeInfo( self.entryModel.smartObject.getServerMeta()) mustAttributes = serverSchema.getAllMusts([objectClass]) mustAttributes = mustAttributes.difference( set(self.entryModel.smartObject.getAttributeList())) attributeSet = mustAttributes.union(set([attribute])) for x in attributeSet: self.entryModel.addAttributeValue(x, None) self.displayValues()
def onServerChanged(self, index): """Slot for the server combo box. When the selected index changes, we want to fetch the baseDN list off of the selected server, and populate the baseDN combo box. :param index: the index of the server entry in the combobox. :type index: int """ server = self.searchForm.server.decode('utf-8') # No need to try to fetch the base dn list off of no server. if server == '': self.searchForm.baseDNBox.clear() return # Get the server object for the selected server. # And return if this object is None self.currentServer = self.serverListObject.getServerObject(server) if self.currentServer is None: return #self.connection = LumaConnection(self.currentServer) con = LumaConnectionWrapper(self.currentServer, self) if self.currentServer.autoBase: #success, baseDNList, e = self.connection.getBaseDNList() success, baseDNList, e = con.getBaseDNListSync() if not success: # TODO: give some visual feedback to the user, regarding # the unsuccessful bind operation msg = 'Could not retrieve baseDN. Reason:\n{0}'.format(str(e)) self.searchForm.onSearchError(True, msg) self.__logger.error(msg) else: baseDNList = [self.currentServer.baseDN] # Try to populate it with the newly fetched baseDN list. # We need make sure the baseDN combo box is cleared before we self.searchForm.populateBaseDNBox(baseDNList) # Try to fetch the list of available attributes, for use in the # filter wizard and for autocompletion. # Jippi ay o' what a beautiful var name!! ocai = ObjectClassAttributeInfo(self.currentServer) attributes = ocai.getAttributeList() objectClasses = ocai.getObjectClasses() self.filterBuilder.onServerChanged(objectClasses, attributes) if self.autocompleteIsEnabled: self.searchForm.initAutoComplete(attributes)
def setData(self, smartObject): """ Sets the current object data, schema information and initializes the attribute box and wizard buttons. """ self.smartObject = smartObject self.SCHEMAINFO = ObjectClassAttributeInfo( self.smartObject.getServerMeta()) self.processData() self.initAttributeBox() currentPageWidget = self.page(0)