Show
Ignore:
Timestamp:
02/17/06 23:51:17 (18 years ago)
Author:
jerome
Message:

pkusers now mostly works. Removing an user from a group with
LDAP is not yet done though. Also no test was done with
LDAP yet.
filldb now really creates users (it uses pkusers instead
of edpykota)

Location:
pykota/trunk/pykota/storages
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • pykota/trunk/pykota/storages/ldapstorage.py

    r2697 r2706  
    982982                group.Members.append(user) 
    983983                 
     984    def delUserFromGroup(self, user, group) :     
     985        """Removes an user from a group.""" 
     986        raise "Not Implemented !" # TODO !!! 
     987                 
    984988    def addUserPQuota(self, user, printer) : 
    985989        """Initializes a user print quota on a printer.""" 
     
    10321036        self.doModify(printer.ident, fields) 
    10331037         
    1034     def writeUserOverCharge(self, user, factor) : 
    1035         """Sets the user's overcharging coefficient.""" 
    1036         fields = { 
    1037                    "pykotaOverCharge" : str(factor), 
    1038                  } 
    1039         self.doModify(user.ident, fields) 
    1040          
    1041     def writeUserLimitBy(self, user, limitby) :     
    1042         """Sets the user's limiting factor.""" 
    1043         fields = { 
    1044                    "pykotaLimitBy" : limitby, 
    1045                  } 
    1046         self.doModify(user.ident, fields)          
    1047          
    1048     def writeGroupLimitBy(self, group, limitby) :     
    1049         """Sets the group's limiting factor.""" 
    1050         fields = { 
    1051                    "pykotaLimitBy" : limitby, 
    1052                  } 
    1053         self.doModify(group.ident, fields)          
     1038    def saveUser(self, user) : 
     1039        """Saves the user to the database in a single operation.""" 
     1040        newfields = { 
     1041                       "pykotaLimitBy" : (user.LimitBy or "quota"), 
     1042                       "pykotaOverCharge" : str(user.OverCharge), 
     1043                    }    
     1044        if user.Email : 
     1045            newfields.update({self.info["usermail"]: user.Email}) 
     1046        if user.Description is not None :  
     1047            newfields.update({"description": self.userCharsetToDatabase(user.Description)}) 
     1048        self.doModify(user.ident, newfields) 
     1049         
     1050    def saveGroup(self, group) : 
     1051        """Saves the group to the database in a single operation.""" 
     1052        newfields = { 
     1053                       "pykotaLimitBy" : (group.LimitBy or "quota"), 
     1054                    }    
     1055        if group.Description is not None :  
     1056            newfields.update({"description": self.userCharsetToDatabase(group.Description)}) 
     1057        self.doModify(group.ident, newfields) 
    10541058         
    10551059    def writeUserPQuotaDateLimit(self, userpquota, datelimit) :     
  • pykota/trunk/pykota/storages/sql.py

    r2698 r2706  
    545545            self.doModify("INSERT INTO groupsmembers (groupid, userid) VALUES (%s, %s)" % (self.doQuote(group.ident), self.doQuote(user.ident))) 
    546546             
     547    def delUserFromGroup(self, user, group) :     
     548        """Removes an user from a group.""" 
     549        self.doModify("DELETE FROM groupsmembers WHERE groupid=%s AND userid=%s" % \ 
     550                       (self.doQuote(group.ident), self.doQuote(user.ident))) 
     551             
    547552    def addUserPQuota(self, user, printer) : 
    548553        """Initializes a user print quota on a printer.""" 
     
    564569                                 self.doQuote(printer.PricePerJob), \ 
    565570                                 self.doQuote(printer.ident))) 
    566          
    567     def writeUserOverCharge(self, user, factor) : 
    568         """Sets the user's overcharging coefficient.""" 
    569         self.doModify("UPDATE users SET overcharge=%s WHERE id=%s" % (self.doQuote(factor), self.doQuote(user.ident))) 
    570          
    571     def writeUserLimitBy(self, user, limitby) :     
    572         """Sets the user's limiting factor.""" 
    573         self.doModify("UPDATE users SET limitby=%s WHERE id=%s" % (self.doQuote(limitby), self.doQuote(user.ident))) 
    574          
    575     def writeGroupLimitBy(self, group, limitby) :     
    576         """Sets the group's limiting factor.""" 
    577         self.doModify("UPDATE groups SET limitby=%s WHERE id=%s" % (self.doQuote(limitby), self.doQuote(group.ident))) 
     571                                  
     572    def saveUser(self, user) :         
     573        """Saves the user to the database in a single operation.""" 
     574        self.doModify("UPDATE users SET limitby=%s, email=%s, overcharge=%s, description=%s WHERE id=%s" \ 
     575                               % (self.doQuote(user.LimitBy or 'quota'), \ 
     576                                  self.doQuote(user.Email), \ 
     577                                  self.doQuote(user.OverCharge), \ 
     578                                  self.doQuote(self.userCharsetToDatabase(user.Description)), \ 
     579                                  self.doQuote(user.ident))) 
     580                                   
     581    def saveGroup(self, group) :         
     582        """Saves the group to the database in a single operation.""" 
     583        self.doModify("UPDATE groups SET limitby=%s, description=%s WHERE id=%s" \ 
     584                               % (self.doQuote(group.LimitBy or 'quota'), \ 
     585                                  self.doQuote(self.userCharsetToDatabase(group.Description)), \ 
     586                                  self.doQuote(group.ident))) 
    578587         
    579588    def writeUserPQuotaDateLimit(self, userpquota, datelimit) :