GroupDialog.py :  » Network » Luma » luma-2.4 » lib » luma » plugins » usermanagement » Python Open Source

Home
Python Open Source
1.3.1.2 Python
2.Ajax
3.Aspect Oriented
4.Blog
5.Build
6.Business Application
7.Chart Report
8.Content Management Systems
9.Cryptographic
10.Database
11.Development
12.Editor
13.Email
14.ERP
15.Game 2D 3D
16.GIS
17.GUI
18.IDE
19.Installer
20.IRC
21.Issue Tracker
22.Language Interface
23.Log
24.Math
25.Media Sound Audio
26.Mobile
27.Network
28.Parser
29.PDF
30.Project Management
31.RSS
32.Search
33.Security
34.Template Engines
35.Test
36.UML
37.USB Serial
38.Web Frameworks
39.Web Server
40.Web Services
41.Web Unit
42.Wiki
43.Windows
44.XML
Python Open Source » Network » Luma 
Luma » luma 2.4 » lib » luma » plugins » usermanagement » GroupDialog.py
# -*- coding: utf-8 -*-

###########################################################################
#    Copyright (C) 2004 by Wido Depping
#    <widod@users.sourceforge.net>
#
# Copyright: See COPYING file that comes with this distribution
#
###########################################################################

from qt import *
import os.path
import ldap

import environment
from plugins.usermanagement.GroupDialogDesign import GroupDialogDesign
from base.backend.LumaConnection import LumaConnection
from base.utils.gui.LumaErrorDialog import LumaErrorDialog


class GroupDialog(GroupDialogDesign):

    def __init__(self,parent = None,name = None,modal = 0,fl = 0):
        GroupDialogDesign.__init__(self,parent,name,modal,fl)
        
        iconDir = os.path.join (environment.lumaInstallationPrefix, "share", "luma", "icons", "plugins", "usermanagement")
        groupPixmap = QPixmap(os.path.join(iconDir, "groupbig.png"))
        self.groupLabel.setPixmap(groupPixmap)
        
        
        self.serverMeta = None
        self.userName = None
        
        self.groupData = {}

###############################################################################

    def retrieveGroups(self):
        tmpText = self.textLabel.text().arg(self.userName)
        self.textLabel.setText(tmpText)
        
        tmpText = self.infoLabel2.text().arg(self.userName)
        self.infoLabel2.setText(tmpText)
        
        connectionObject = LumaConnection(self.serverMeta)
        bindSuccess, exceptionObject = connectionObject.bind()
        
        if not bindSuccess:
                dialog = LumaErrorDialog()
                errorMsg = self.trUtf8("Could not bind to server.<br><br>Reason: ")
                errorMsg.append(str(exceptionObject))
                dialog.setErrorMessage(errorMsg)
                dialog.exec_loop()
        
        success, resultList, exceptionObject = connectionObject.search(self.serverMeta.currentBase, ldap.SCOPE_SUBTREE, 
                "objectClass=posixGroup", )
                
        connectionObject.unbind()
        
        if success:
            self.processResults(resultList)
        else:
            dialog = LumaErrorDialog()
            errorMsg = self.trUtf8("Could retrieve other group information.<br><br>Reason: ")
            errorMsg.append(str(exceptionObject))
            dialog.setErrorMessage(errorMsg)
            dialog.exec_loop()
        
###############################################################################

    def processResults(self, results):
        for x in results:
            self.groupData[x.getDN()] = x
           
        tmpList = ['']
        for x in self.groupData.keys():
            name = self.groupData[x].getAttributeValue('cn', 0)
            groupNumber = self.groupData[x].getAttributeValue('gidNumber', 0)
            
            item = QCheckListItem(self.groupView, name, QCheckListItem.CheckBox)
            if self.groupData[x].hasAttribute("memberUid"):
                if self.userName in self.groupData[x].getAttributeValueList("memberUid"):
                    item.setOn(True)
            item.setText(1, groupNumber)
            item.setText(2, x)
            
            tmpList.append(name)
            
        tmpList.sort()
        map(self.groupNameBox.insertItem, tmpList)
        
###############################################################################

    def groupNameChanged(self, groupString):
        groupString = unicode(groupString)
        
        for x in self.groupData.keys():
            if self.groupData[x].getAttributeValue('cn', 0) == groupString:
                self.groupNumberBox.blockSignals(True)
                self.groupNumberBox.setValue(int(self.groupData[x].getAttributeValue('gidNumber',0)))
                self.groupNumberBox.blockSignals(False)
        
###############################################################################
        
    def groupNumberChanged(self, groupNumber):
        newGroup = None
        
        for x in self.groupData.keys():
            if int(self.groupData[x].getAttributeValue('gidNumber', 0)) == groupNumber:
                newGroup = self.groupData[x].getAttributeValue('cn', 0)
                break
                
        # If the groupnumber belongs to a non-ldap group, reset the group in 
        # the toolbox.
        if newGroup == None:
            newGroup = ""
            
        self.groupNameBox.blockSignals(True)
        self.groupNameBox.setCurrentText(newGroup)
        self.groupNameBox.blockSignals(False)
        
        
        
        
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.