Changeset 1018

Show
Ignore:
Timestamp:
06/06/03 22:49:15 (21 years ago)
Author:
jalet
Message:

Very latest schema. UNTESTED.

Location:
pykota/trunk
Files:
6 modified

Legend:

Unmodified
Added
Removed
  • pykota/trunk/CREDITS

    r1017 r1018  
    4040  The following people contributed code or ideas to PyKota : 
    4141   
    42     - Jo�Collet : made the PyKota logo 
     42    - Jo�Collet : PyKota's logo 
    4343    - Stefan Wold - Stockholm University : code 
    4444    - John Flynn - University of Belize : LDAP support 
    4545    - Wayne Godoy - University of Belize : LDAP support 
    46     - Leif Johansson - LDAP support 
     46    - Leif Johansson - Stockholm University : LDAP support 
    4747 
    4848============================================================ 
  • pykota/trunk/initscripts/ldap/pykota-sample.ldif

    r1017 r1018  
    7272 
    7373dn: cn=apple,ou=Printers,ou=PyKota,dc=librelogiciel,dc=com 
    74 objectClass: pykotaNamed 
     74objectClass: pykotaObject 
    7575objectClass: pykotaPrinter 
    7676cn: apple 
     
    8080 
    8181dn: cn=uniqueidentifier01,ou=UQuotas,ou=PyKota,dc=librelogiciel,dc=com 
    82 objectClass: pykotaNamed 
     82objectClass: pykotaObject 
    8383objectClass: pykotaUserPQuota 
    8484cn: uniqueidentifier01 
     
    9292 
    9393dn: cn=uniqueidentifier02,ou=GQuotas,ou=PyKota,dc=librelogiciel,dc=com 
    94 objectClass: pykotaNamed 
     94objectClass: pykotaObject 
    9595objectClass: pykotaGroupPQuota 
    9696cn: uniqueidentifier02 
     
    102102 
    103103dn: cn=uniqueidentifier03,ou=Jobs,ou=PyKota,dc=librelogiciel,dc=com 
    104 objectClass: pykotaNamed 
     104objectClass: pykotaObject 
    105105objectClass: pykotaJob 
    106106cn: uniqueidentifier03 
     
    113113 
    114114dn: cn=uniqueidentifier04,ou=LastJobs,ou=PyKota,dc=librelogiciel,dc=com 
    115 objectClass: pykotaNamed 
     115objectClass: pykotaObject 
    116116objectClass: pykotaLastJob 
    117117cn: uniqueidentifier04 
    118118pykotaPrinterName: apple 
    119 pykotaLastJobUUID: uniqueidentifier03 
     119pykotaLastJobIdent: uniqueidentifier03 
  • pykota/trunk/initscripts/ldap/pykota.schema

    r1017 r1018  
    110110# pykotaAction 
    111111attributetype ( 1.3.6.1.4.1.16868.1.1.14 NAME 'pykotaAction' 
    112         DESC 'Was the job allowed, or denied' 
    113         EQUALITY caseIgnoreIA5Match 
     112        DESC 'Was the job allowed, or denied : ( "ALLOW" |  "DENY" )' 
     113        EQUALITY caseExactIA5Match 
    114114        SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 SINGLE-VALUE ) 
    115115         
     
    132132        SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 SINGLE-VALUE ) 
    133133         
    134 # pykotaLastJobUUID         
    135 attributetype ( 1.3.6.1.4.1.16868.1.1.18 NAME 'pykotaLastJobUUID' 
    136         DESC 'Last job uuid in the history' 
     134# pykotaLastJobIdent         
     135attributetype ( 1.3.6.1.4.1.16868.1.1.18 NAME 'pykotaLastJobIdent' 
     136        DESC 'Identifies the last job in the history' 
    137137        EQUALITY caseExactIA5Match 
    138138        SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 SINGLE-VALUE ) 
     
    145145objectclass ( 1.3.6.1.4.1.16868.1.2.1 NAME 'pykotaAccount' SUP top AUXILIARY 
    146146        DESC 'PyKota Auxiliary User Account' 
    147         MUST ( uid $ pykotaUserName ) 
    148         MAY  ( pykotaLimitBy ) ) 
     147        MUST ( uid ) 
     148        MAY  ( pykotaUserName $ pykotaLimitBy ) ) 
    149149         
    150150# pykotaGroup         
    151151objectclass ( 1.3.6.1.4.1.16868.1.2.2 NAME 'pykotaGroup' SUP top AUXILIARY 
    152152        DESC 'PyKota Auxiliary Group' 
    153         MUST ( cn $ pykotaGroupName ) 
    154         MAY  ( pykotaLimitBy $ memberUid ) ) 
     153        MUST ( cn ) 
     154        MAY  ( pykotaGroupName $ pykotaLimitBy $ memberUid $ uniqueMember $ member ) ) 
    155155         
    156156# pykotaPrinter         
    157157objectclass ( 1.3.6.1.4.1.16868.1.2.3 NAME 'pykotaPrinter' SUP top AUXILIARY 
    158158        DESC 'PyKota Printer' 
    159         MUST ( cn $ pykotaPrinterName ) 
    160         MAY  ( pykotaPricePerPage $ pykotaPricePerJob ) ) 
     159        MUST ( cn ) 
     160        MAY  ( pykotaPrinterName $ pykotaPricePerPage $ pykotaPricePerJob ) ) 
    161161         
    162162# pykotaUserPQuota         
     
    181181objectclass ( 1.3.6.1.4.1.16868.1.2.7 NAME 'pykotaAccountBalance' SUP top AUXILIARY 
    182182        DESC 'PyKota User account balance' 
    183         MUST ( pykotaUserName ) 
    184         MAY  ( pykotaBalance $ pykotaLifeTimePaid ) ) 
     183        MAY  ( pykotaUserName $ pykotaBalance $ pykotaLifeTimePaid ) ) 
    185184         
    186185# pykotaLastJob         
    187186objectclass ( 1.3.6.1.4.1.16868.1.2.8 NAME 'pykotaLastJob' SUP top AUXILIARY 
    188187        DESC 'Last job information for a printer' 
    189         MUST ( pykotaPrinterName $ pykotaLastJobUUID ) ) 
     188        MUST ( pykotaLastJobIdent ) 
     189        MAY ( pykotaPrinterName ) )  
    190190         
    191 # pykotaNamed - Use it if you have to  
    192 objectclass ( 1.3.6.1.4.1.16868.1.2.9 NAME 'pykotaNamed' SUP top STRUCTURAL 
    193         DESC 'PyKota Named Object' 
     191# pykotaObject - Use it if you have to  
     192objectclass ( 1.3.6.1.4.1.16868.1.2.9 NAME 'pykotaObject' SUP top STRUCTURAL 
     193        DESC 'PyKota Object' 
    194194        MUST ( cn ) ) 
    195195         
  • pykota/trunk/pykota/storages/ldapstorage.py

    r1017 r1018  
    2121# 
    2222# $Log$ 
     23# Revision 1.3  2003/06/06 20:49:15  jalet 
     24# Very latest schema. UNTESTED. 
     25# 
    2326# Revision 1.2  2003/06/06 14:21:08  jalet 
    2427# New LDAP schema. 
     
    8689    def getPrinterId(self, printername) :         
    8790        """Returns a printerid given a printername.""" 
    88         result = self.doSearch("(&(objectClass=pykotaPrinter)(pykotaPrinterName=%s))" % printername, ["pykotaPrinterName"]) 
     91        result = self.doSearch("(&(objectClass=pykotaPrinter)(|(pykotaPrinterName=%s)(cn=%s)))" % (printername, printername), ["pykotaPrinterName"]) 
    8992        if result : 
    9093            return result[0][0] 
     
    9295    def getPrinterPrices(self, printerid) :         
    9396        """Returns a printer prices per page and per job given a printerid.""" 
    94         result = self.doSearch("pykotaPrinterName=*", ["pykotaPricePerPage", "pykotaPricePerJob"], base=printerid) 
     97        result = self.doSearch("(|(pykotaPrinterName=*)(cn=*))", ["pykotaPricePerPage", "pykotaPricePerJob"], base=printerid, scope=ldap.SCOPE_BASE) 
    9598        if result : 
    9699            return (float(result[0][1]["pykotaPricePerPage"][0]), float(result[0][1]["pykotaPricePerJob"][0])) 
     
    102105    def getUserId(self, username) : 
    103106        """Returns a userid given a username.""" 
    104         result = self.doSearch("(&(objectClass=pykotaAccount)(pykotaUserName=%s))" % username, ["uid"]) 
     107        result = self.doSearch("(&(objectClass=pykotaAccount)(|(pykotaUserName=%s)(uid=%s)))" % (username, username), ["uid"]) 
    105108        if result : 
    106109            return result[0][0] 
     
    108111    def getGroupId(self, groupname) : 
    109112        """Returns a groupid given a grupname.""" 
    110         result = self.doSearch("(&(objectClass=pykotaGroup)(pykotaGroupName=%s))" % groupname, ["cn"]) 
     113        result = self.doSearch("(&(objectClass=pykotaGroup)(|(pykotaGroupName=%s)(cn=%s)))" % (groupname, groupname), ["cn"]) 
    111114        if result is not None : 
    112115            (groupid, dummy) = result[0] 
     
    120123        """Returns the list of userids and usernames which uses a given printer.""" 
    121124        # first get the printer's name from the id 
    122         result = self.doSearch("objectClass=pykotaPrinter", ["pykotaPrinterName"], base=printerid, scope=ldap.SCOPE_BASE) 
    123         if result : 
    124             printername = result[0][1]["pykotaPrinterName"][0] 
     125        result = self.doSearch("objectClass=pykotaPrinter", ["pykotaPrinterName", "cn"], base=printerid, scope=ldap.SCOPE_BASE) 
     126        if result : 
     127            fields = result[0][1] 
     128            printername = (fields.get("pykotaPrinterName") or fields.get("cn"))[0] 
    125129            result = self.doSearch("(&(objectClass=pykotaUserPQuota)(pykotaPrinterName=%s))" % printername, ["pykotaUserName"])  
    126130            if result : 
     
    130134        """Returns the list of groups which uses a given printer.""" 
    131135        # first get the printer's name from the id 
    132         result = self.doSearch("objectClass=pykotaPrinter", ["pykotaPrinterName"], base=printerid, scope=ldap.SCOPE_BASE) 
    133         if result : 
    134             printername = result[0][1]["pykotaPrinterName"][0] 
     136        result = self.doSearch("objectClass=pykotaPrinter", ["pykotaPrinterName", "cn"], base=printerid, scope=ldap.SCOPE_BASE) 
     137        if result : 
     138            fields = result[0][1] 
     139            printername = (fields.get("pykotaPrinterName") or fields.get("cn"))[0] 
    135140            result = self.doSearch("(&(objectClass=pykotaGroupPQuota)(pykotaPrinterName=%s))" % printername, ["pykotaGroupName"])  
    136141            if result : 
     
    139144    def getGroupMembersNames(self, groupname) :         
    140145        """Returns the list of user's names which are member of this group.""" 
    141         result = self.doSearch("(&(objectClass=pykotaGroup)(pykotaGroupName=%s))" % groupname, ["memberUid"]) 
    142         if result : 
    143             return result[0][1]["memberUid"] 
     146        result = self.doSearch("(&(objectClass=pykotaGroup)(|(pykotaGroupName=%s)(cn=%s)))" % (groupname, groupname), ["memberUid", "uniqueMember", "member"]) 
     147        if result : 
     148            fields = result[0][1] 
     149            return fields.get("memberUid") or fields.get("uniqueMember") or fields.get("member") 
    144150         
    145151    def getUserGroupsNames(self, userid) :         
     
    177183        if result : 
    178184            username = result[0][1]["pykotaUserName"][0] 
    179             result = self.doSearch("(&(objectClass=pykotaAccountBalance)(pykotaUserName=%s))" % username, ["pykotaBalance", "pykotaLifeTimePaid"]) 
     185            result = self.doSearch("(&(objectClass=pykotaAccountBalance)(|(pykotaUserName=%s)(uid=%s)))" % (username, username), ["pykotaBalance", "pykotaLifeTimePaid"]) 
    180186            if result : 
    181187                fields = result[0][1] 
     
    185191        """Returns the current account balance for a given user id.""" 
    186192        # first get the user's name from the user id 
    187         result = self.doSearch("objectClass=pykotaAccount", ["pykotaUserName"], base=userid, scope=ldap.SCOPE_BASE) 
    188         if result : 
    189             username = result[0][1]["pykotaUserName"][0] 
    190             result = self.doSearch("(&(objectClass=pykotaAccountBalance)(pykotaUserName=%s))" % username, ["pykotaBalance", "pykotaLifeTimePaid"]) 
     193        result = self.doSearch("objectClass=pykotaAccount", ["pykotaUserName", "uid"], base=userid, scope=ldap.SCOPE_BASE) 
     194        if result : 
     195            fields = result[0][1] 
     196            username = (fields.get("pykotaUserName") or fields.get("uid"))[0] 
     197            result = self.doSearch("(&(objectClass=pykotaAccountBalance)(|(pykotaUserName=%s)(uid=%s)))" % (username, username), ["pykotaBalance", "pykotaLifeTimePaid"]) 
    191198            if result : 
    192199                fields = result[0][1] 
  • pykota/trunk/pykota/version.py

    r1017 r1018  
    2121# 
    2222 
    23 __version__ = "1.08alpha6_unofficial" 
     23__version__ = "1.08alpha7_unofficial" 
    2424 
    2525__doc__ = """PyKota : a complete Printing Quota Solution for CUPS and LPRng.""" 
  • pykota/trunk/setup.py

    r997 r1018  
    2323# 
    2424# $Log$ 
     25# Revision 1.16  2003/06/06 20:49:15  jalet 
     26# Very latest schema. UNTESTED. 
     27# 
    2528# Revision 1.15  2003/05/17 16:32:30  jalet 
    2629# Also outputs the original import error message. 
     
    111114    return result 
    112115     
    113 def checkWithPrompt(prompt, module=None, command=None, help=None) : 
     116def checkWithPrompt(prompt, module=None, command=None, helper=None) : 
    114117    """Tells the user what will be checked, and asks him what to do if something is absent.""" 
    115118    sys.stdout.write("Checking for %s availability : " % prompt) 
     
    125128        sys.stdout.write("NO.\n") 
    126129        sys.stderr.write("ERROR : %s not available !\n" % prompt) 
    127         if help is not None : 
    128             sys.stdout.write("%s\n" % help) 
     130        if helper is not None : 
     131            sys.stdout.write("%s\n" % helper) 
    129132            sys.stdout.write("You may continue safely if you don't need this functionnality.\n") 
    130133        answer = raw_input("%s is missing. Do you want to continue anyway (y/N) ? " % prompt) 
     
    190193     
    191194    # checks if some needed Python modules are there or not. 
    192     modulestocheck = [("PygreSQL", "pg"), ("mxDateTime", "mx.DateTime")] 
     195    modulestocheck = [ ("PygreSQL", "pg", "PygreSQL is mandatory if you want to use PostgreSQL as the quota storage backend."),                                             
     196                       ("mxDateTime", "mx.DateTime", "eGenix' mxDateTime is mandatory for PyKota to work."),  
     197                       ("Python-LDAP", "ldap", "Python-LDAP is mandatory if you plan to use an LDAP\ndirectory as the quota storage backend.") 
     198                     ] 
    193199    commandstocheck = [("SNMP Tools", "snmpget", "SNMP Tools are needed if you want to use SNMP enabled printers."), ("Netatalk", "pap", "Netatalk is needed if you want to use AppleTalk enabled printers.")] 
    194     for (name, module) in modulestocheck : 
    195         action = checkWithPrompt(name, module=module) 
     200    for (name, module, helper) in modulestocheck : 
     201        action = checkWithPrompt(name, module=module, helper=helper) 
    196202        if action == ACTION_ABORT : 
    197203            sys.stderr.write("Aborted !\n") 
     
    199205             
    200206    # checks if some software are there or not. 
    201     for (name, command, help) in commandstocheck : 
    202         action = checkWithPrompt(name, command=command, help=help) 
     207    for (name, command, helper) in commandstocheck : 
     208        action = checkWithPrompt(name, command=command, helper=helper) 
    203209        if action == ACTION_ABORT : 
    204210            sys.stderr.write("Aborted !\n")