Changeset 1742 for pykota/trunk/pykota/storages
- Timestamp:
- 09/24/04 22:21:50 (20 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
pykota/trunk/pykota/storages/ldapstorage.py
r1692 r1742 22 22 # 23 23 # $Log$ 24 # Revision 1.75 2004/09/24 20:21:50 jalet 25 # Fixed pykotaAccountBalance object location during creation 26 # 24 27 # Revision 1.74 2004/09/02 10:09:30 jalet 25 28 # Fixed bug in LDAP user deletion code which didn't correctly delete the user's … … 501 504 user.LimitBy = user.LimitBy[0] 502 505 result = self.doSearch("(&(objectClass=pykotaAccountBalance)(|(pykotaUserName=%s)(%s=%s)))" % (username, self.info["balancerdn"], username), ["pykotaBalance", "pykotaLifeTimePaid", "pykotaPayments"], base=self.info["balancebase"]) 503 if result : 506 if not result : 507 raise PyKotaStorageError, _("No pykotaAccountBalance object found for user %s. Did you create LDAP entries manually ?") % username 508 else : 504 509 fields = result[0][1] 505 510 user.idbalance = result[0][0] … … 803 808 newfields = { 804 809 "pykotaUserName" : user.Name, 805 "pykotaLimitBY" : (user.LimitBy or "quota"), 806 "pykotaBalance" : str(user.AccountBalance or 0.0), 807 "pykotaLifeTimePaid" : str(user.LifeTimePaid or 0.0), 810 "pykotaLimitBy" : (user.LimitBy or "quota"), 808 811 } 812 809 813 if user.Email : 810 814 newfields.update({self.info["usermail"]: user.Email}) … … 820 824 fields["objectClass"].extend(["pykotaAccount", "pykotaAccountBalance"]) 821 825 fields.update(newfields) 826 fields.update({ "pykotaBalance" : str(user.AccountBalance or 0.0), 827 "pykotaLifeTimePaid" : str(user.LifeTimePaid or 0.0), }) 822 828 self.doModify(dn, fields) 823 829 mustadd = 0 … … 830 836 831 837 if mustadd : 832 fields = { self.info["userrdn"] : user.Name, 833 "objectClass" : ["pykotaObject", "pykotaAccount", "pykotaAccountBalance"], 834 "cn" : user.Name, 835 } 838 if self.info["userbase"] == self.info["balancebase"] : 839 fields = { self.info["userrdn"] : user.Name, 840 "objectClass" : ["pykotaObject", "pykotaAccount", "pykotaAccountBalance"], 841 "cn" : user.Name, 842 "pykotaBalance" : str(user.AccountBalance or 0.0), 843 "pykotaLifeTimePaid" : str(user.LifeTimePaid or 0.0), 844 } 845 else : 846 fields = { self.info["userrdn"] : user.Name, 847 "objectClass" : ["pykotaObject", "pykotaAccount"], 848 "cn" : user.Name, 849 } 836 850 fields.update(newfields) 837 851 dn = "%s=%s,%s" % (self.info["userrdn"], user.Name, self.info["userbase"]) 838 852 self.doAdd(dn, fields) 853 if self.info["userbase"] != self.info["balancebase"] : 854 fields = { self.info["balancerdn"] : user.Name, 855 "objectClass" : ["pykotaObject", "pykotaAccountBalance"], 856 "cn" : user.Name, 857 "pykotaBalance" : str(user.AccountBalance or 0.0), 858 "pykotaLifeTimePaid" : str(user.LifeTimePaid or 0.0), 859 } 860 dn = "%s=%s,%s" % (self.info["balancerdn"], user.Name, self.info["balancebase"]) 861 self.doAdd(dn, fields) 862 839 863 return self.getUser(user.Name) 840 864