Changeset 2721
- Timestamp:
- 02/20/06 23:26:45 (19 years ago)
- Location:
- pykota/trunk/pykota/storages
- Files:
-
- 2 modified
Legend:
- Unmodified
- Added
- Removed
-
pykota/trunk/pykota/storages/ldapstorage.py
r2718 r2721 355 355 user = StorageUser(self, username) 356 356 username = self.userCharsetToDatabase(username) 357 result = self.doSearch("(&(objectClass=pykotaAccount)(|(pykotaUserName=%s)(%s=%s)))" % (username, self.info["userrdn"], username), ["pykotaUserName", "pykotaLimitBy", self.info["usermail"], "pykotaOverCharge" ], base=self.info["userbase"])357 result = self.doSearch("(&(objectClass=pykotaAccount)(|(pykotaUserName=%s)(%s=%s)))" % (username, self.info["userrdn"], username), ["pykotaUserName", "pykotaLimitBy", self.info["usermail"], "pykotaOverCharge", "description"], base=self.info["userbase"]) 358 358 if result : 359 359 fields = result[0][1] 360 360 user.ident = result[0][0] 361 user.Description = self.databaseToUserCharset(fields.get("description", [None])[0]) 361 362 user.Email = fields.get(self.info["usermail"], [None])[0] 362 363 user.LimitBy = fields.get("pykotaLimitBy", ["quota"])[0] … … 400 401 group = StorageGroup(self, groupname) 401 402 groupname = self.userCharsetToDatabase(groupname) 402 result = self.doSearch("(&(objectClass=pykotaGroup)(|(pykotaGroupName=%s)(%s=%s)))" % (groupname, self.info["grouprdn"], groupname), ["pykotaGroupName", "pykotaLimitBy" ], base=self.info["groupbase"])403 result = self.doSearch("(&(objectClass=pykotaGroup)(|(pykotaGroupName=%s)(%s=%s)))" % (groupname, self.info["grouprdn"], groupname), ["pykotaGroupName", "pykotaLimitBy", "description"], base=self.info["groupbase"]) 403 404 if result : 404 405 fields = result[0][1] 405 406 group.ident = result[0][0] 406 407 group.Name = fields.get("pykotaGroupName", [self.databaseToUserCharset(groupname)])[0] 408 group.Description = self.databaseToUserCharset(fields.get("description", [None])[0]) 407 409 group.LimitBy = fields.get("pykotaLimitBy", ["quota"])[0] 408 410 group.AccountBalance = 0.0 … … 701 703 # see comment at the same place in pgstorage.py 702 704 result = self.doSearch("objectClass=pykotaAccount", \ 703 ["pykotaUserName", "pykotaLimitBy", self.info["usermail"], "pykotaOverCharge" ], \705 ["pykotaUserName", "pykotaLimitBy", self.info["usermail"], "pykotaOverCharge", "description"], \ 704 706 base=self.info["userbase"]) 705 707 if result : … … 713 715 user.LimitBy = fields.get("pykotaLimitBy", ["quota"])[0] 714 716 user.OverCharge = float(fields.get("pykotaOverCharge", [1.0])[0]) 717 user.Description = self.databaseToUserCharset(fields.get("description", [""])[0]) 715 718 uname = self.userCharsetToDatabase(username) 716 719 result = self.doSearch("(&(objectClass=pykotaAccountBalance)(|(pykotaUserName=%s)(%s=%s)))" % \ … … 758 761 # see comment at the same place in pgstorage.py 759 762 result = self.doSearch("objectClass=pykotaGroup", \ 760 ["pykotaGroupName", "pykotaLimitBy" ], \763 ["pykotaGroupName", "pykotaLimitBy", "description"], \ 761 764 base=self.info["groupbase"]) 762 765 if result : … … 769 772 group.Name = fields.get("pykotaGroupName", [self.databaseToUserCharset(groupname)])[0] 770 773 group.LimitBy = fields.get("pykotaLimitBy", ["quota"])[0] 774 group.Description = self.databaseToUserCharset(fields.get("description", [""])[0]) 771 775 group.AccountBalance = 0.0 772 776 group.LifeTimePaid = 0.0 … … 867 871 "pykotaLimitBy" : (user.LimitBy or "quota"), 868 872 "pykotaOverCharge" : str(user.OverCharge), 873 "description" : self.userCharsetToDatabase(user.Description or "") 869 874 } 870 875 871 876 if user.Email : 872 877 newfields.update({self.info["usermail"]: user.Email}) 873 if user.Description is not None :874 newfields.update({"description": self.userCharsetToDatabase(user.Description)})875 878 mustadd = 1 876 879 if self.info["newuser"].lower() != 'below' : … … 933 936 "pykotaGroupName" : gname, 934 937 "pykotaLimitBy" : (group.LimitBy or "quota"), 938 "description" : self.userCharsetToDatabase(group.Description or "") 935 939 } 936 if group.Description is not None :937 newfields.update({"description": self.userCharsetToDatabase(group.Description)})938 940 mustadd = 1 939 941 if self.info["newgroup"].lower() != 'below' : … … 1041 1043 "pykotaLimitBy" : (user.LimitBy or "quota"), 1042 1044 "pykotaOverCharge" : str(user.OverCharge), 1045 "description" : self.userCharsetToDatabase(user.Description or ""), 1043 1046 } 1044 1047 if user.Email : 1045 1048 newfields.update({self.info["usermail"]: user.Email}) 1046 if user.Description is not None :1047 newfields.update({"description": self.userCharsetToDatabase(user.Description)})1048 1049 self.doModify(user.ident, newfields) 1049 1050 … … 1057 1058 newfields = { 1058 1059 "pykotaLimitBy" : (group.LimitBy or "quota"), 1060 "description" : self.userCharsetToDatabase(group.Description or ""), 1059 1061 } 1060 if group.Description is not None :1061 newfields.update({"description": self.userCharsetToDatabase(group.Description)})1062 1062 self.doModify(group.ident, newfields) 1063 1063 … … 1480 1480 entries = [u for u in [self.getUser(name) for name in self.getAllUsersNames(uname)] if u.Exists] 1481 1481 if entries : 1482 result = [ ("dn", "username", "balance", "lifetimepaid", "limitby", "email" ) ]1482 result = [ ("dn", "username", "balance", "lifetimepaid", "limitby", "email", "description") ] 1483 1483 for entry in entries : 1484 result.append((entry.ident, entry.Name, entry.AccountBalance, entry.LifeTimePaid, entry.LimitBy, entry.Email ))1484 result.append((entry.ident, entry.Name, entry.AccountBalance, entry.LifeTimePaid, entry.LimitBy, entry.Email, entry.Description)) 1485 1485 return result 1486 1486 … … 1500 1500 entries = [g for g in [self.getGroup(name) for name in self.getAllGroupsNames(gname)] if g.Exists] 1501 1501 if entries : 1502 result = [ ("dn", "groupname", "limitby", "balance", "lifetimepaid" ) ]1502 result = [ ("dn", "groupname", "limitby", "balance", "lifetimepaid", "description") ] 1503 1503 for entry in entries : 1504 result.append((entry.ident, entry.Name, entry.LimitBy, entry.AccountBalance, entry.LifeTimePaid ))1504 result.append((entry.ident, entry.Name, entry.LimitBy, entry.AccountBalance, entry.LifeTimePaid, entry.Description)) 1505 1505 return result 1506 1506 -
pykota/trunk/pykota/storages/sql.py
r2718 r2721 477 477 user.Email = record.get("email") 478 478 user.OverCharge = record.get("overcharge") 479 user.Description = self.databaseToUserCharset(record.get("description")) 479 480 user.Exists = 1 480 481 userpquota = StorageUserPQuota(self, user, printer)