Index: /pykota/trunk/pykota/storages/ldapstorage.py
===================================================================
--- /pykota/trunk/pykota/storages/ldapstorage.py (revision 1692)
+++ /pykota/trunk/pykota/storages/ldapstorage.py (revision 1742)
@@ -22,4 +22,7 @@
 #
 # $Log$
+# Revision 1.75  2004/09/24 20:21:50  jalet
+# Fixed pykotaAccountBalance object location during creation
+#
 # Revision 1.74  2004/09/02 10:09:30  jalet
 # Fixed bug in LDAP user deletion code which didn't correctly delete the user's
@@ -501,5 +504,7 @@
                 user.LimitBy = user.LimitBy[0]
             result = self.doSearch("(&(objectClass=pykotaAccountBalance)(|(pykotaUserName=%s)(%s=%s)))" % (username, self.info["balancerdn"], username), ["pykotaBalance", "pykotaLifeTimePaid", "pykotaPayments"], base=self.info["balancebase"])
-            if result :
+            if not result :
+                raise PyKotaStorageError, _("No pykotaAccountBalance object found for user %s. Did you create LDAP entries manually ?") % username
+            else :
                 fields = result[0][1]
                 user.idbalance = result[0][0]
@@ -803,8 +808,7 @@
         newfields = {
                        "pykotaUserName" : user.Name,
-                       "pykotaLimitBY" : (user.LimitBy or "quota"),
-                       "pykotaBalance" : str(user.AccountBalance or 0.0),
-                       "pykotaLifeTimePaid" : str(user.LifeTimePaid or 0.0),
+                       "pykotaLimitBy" : (user.LimitBy or "quota"),
                     }   
+                       
         if user.Email :
             newfields.update({self.info["usermail"]: user.Email})
@@ -820,4 +824,6 @@
                 fields["objectClass"].extend(["pykotaAccount", "pykotaAccountBalance"])
                 fields.update(newfields)
+                fields.update({ "pykotaBalance" : str(user.AccountBalance or 0.0),
+                                "pykotaLifeTimePaid" : str(user.LifeTimePaid or 0.0), })   
                 self.doModify(dn, fields)
                 mustadd = 0
@@ -830,11 +836,29 @@
                 
         if mustadd :
-            fields = { self.info["userrdn"] : user.Name,
-                       "objectClass" : ["pykotaObject", "pykotaAccount", "pykotaAccountBalance"],
-                       "cn" : user.Name,
-                     } 
+            if self.info["userbase"] == self.info["balancebase"] :            
+                fields = { self.info["userrdn"] : user.Name,
+                           "objectClass" : ["pykotaObject", "pykotaAccount", "pykotaAccountBalance"],
+                           "cn" : user.Name,
+                           "pykotaBalance" : str(user.AccountBalance or 0.0),
+                           "pykotaLifeTimePaid" : str(user.LifeTimePaid or 0.0), 
+                         } 
+            else :             
+                fields = { self.info["userrdn"] : user.Name,
+                           "objectClass" : ["pykotaObject", "pykotaAccount"],
+                           "cn" : user.Name,
+                         } 
             fields.update(newfields)         
             dn = "%s=%s,%s" % (self.info["userrdn"], user.Name, self.info["userbase"])
             self.doAdd(dn, fields)
+            if self.info["userbase"] != self.info["balancebase"] :            
+                fields = { self.info["balancerdn"] : user.Name,
+                           "objectClass" : ["pykotaObject", "pykotaAccountBalance"],
+                           "cn" : user.Name,
+                           "pykotaBalance" : str(user.AccountBalance or 0.0),
+                           "pykotaLifeTimePaid" : str(user.LifeTimePaid or 0.0),  
+                         } 
+                dn = "%s=%s,%s" % (self.info["balancerdn"], user.Name, self.info["balancebase"])
+                self.doAdd(dn, fields)
+            
         return self.getUser(user.Name)
         
Index: /pykota/trunk/pykota/storage.py
===================================================================
--- /pykota/trunk/pykota/storage.py (revision 1711)
+++ /pykota/trunk/pykota/storage.py (revision 1742)
@@ -22,4 +22,7 @@
 #
 # $Log$
+# Revision 1.60  2004/09/24 20:21:50  jalet
+# Fixed pykotaAccountBalance object location during creation
+#
 # Revision 1.59  2004/09/10 21:32:52  jalet
 # Small fixes for incomplete entry intialization
@@ -544,4 +547,5 @@
     def getFromCache(self, cachetype, key) :
         """Tries to extract something from the cache."""
+        entry = None    # just to please pychecker
         if self.usecache :
             entry = self.caches[cachetype].get(key)
@@ -550,5 +554,5 @@
             else :    
                 self.tool.logdebug("Cache miss (%s->%s)" % (cachetype, key))
-            return entry    
+        return entry    
             
     def cacheEntry(self, cachetype, key, value) :        
Index: /pykota/trunk/pykota/version.py
===================================================================
--- /pykota/trunk/pykota/version.py (revision 1740)
+++ /pykota/trunk/pykota/version.py (revision 1742)
@@ -22,5 +22,5 @@
 #
 
-__version__ = "1.20alpha14_unofficial"
+__version__ = "1.20alpha15_unofficial"
 
 __doc__ = """PyKota : a complete Printing Quota Solution for CUPS and LPRng."""
Index: /pykota/trunk/NEWS
===================================================================
--- /pykota/trunk/NEWS (revision 1741)
+++ /pykota/trunk/NEWS (revision 1742)
@@ -22,4 +22,11 @@
 PyKota NEWS :
 
+    - 1.20alpha15 :
+    
+        - LDAP pykotaAccountBalance objects were always created
+          attached to the pykotaUser objects. This is now
+          fixed and the value of balancebase in pykota.conf
+          is now correctly used.
+          
     - 1.20alpha14 :
     
