Index: /pykota/trunk/pykota/storages/ldapstorage.py
===================================================================
--- /pykota/trunk/pykota/storages/ldapstorage.py (revision 3307)
+++ /pykota/trunk/pykota/storages/ldapstorage.py (revision 3363)
@@ -366,5 +366,5 @@
             user.Description = databaseToUnicode(fields.get("description", [None])[0])
             user.Email = fields.get(self.info["usermail"], [None])[0]
-            user.LimitBy = fields.get("pykotaLimitBy", ["quota"])[0]
+            user.LimitBy = databaseToUnicode(fields.get("pykotaLimitBy", ["quota"])[0])
             result = self.doSearch("(&(objectClass=pykotaAccountBalance)(|(pykotaUserName=%s)(%s=%s)))" % (username, self.info["balancerdn"], username), ["pykotaBalance", "pykotaLifeTimePaid", "pykotaPayments", "pykotaOverCharge"], base=self.info["balancebase"])
             if not result :
@@ -414,5 +414,5 @@
             group.Name = fields.get("pykotaGroupName", [databaseToUnicode(groupname)])[0] 
             group.Description = databaseToUnicode(fields.get("description", [None])[0])
-            group.LimitBy = fields.get("pykotaLimitBy", ["quota"])[0]
+            group.LimitBy = databaseToUnicode(fields.get("pykotaLimitBy", ["quota"])[0])
             group.AccountBalance = 0.0
             group.LifeTimePaid = 0.0
@@ -659,7 +659,7 @@
                     group.LimitBy = fields.get("pykotaLimitBy")
                     if group.LimitBy is not None :
-                        group.LimitBy = group.LimitBy[0]
+                        group.LimitBy = databaseToUnicode(group.LimitBy[0])
                     else :    
-                        group.LimitBy = "quota"
+                        group.LimitBy = u"quota"
                     group.AccountBalance = 0.0
                     group.LifeTimePaid = 0.0
@@ -746,5 +746,5 @@
                     user.ident = userid
                     user.Email = fields.get(self.info["usermail"], [None])[0]
-                    user.LimitBy = fields.get("pykotaLimitBy", ["quota"])[0]
+                    user.LimitBy = databaseToUnicode(fields.get("pykotaLimitBy", ["quota"])[0])
                     user.Description = databaseToUnicode(fields.get("description", [""])[0]) 
                     uname = unicodeToDatabase(username)
@@ -812,6 +812,6 @@
                     group = StorageGroup(self, groupname)
                     group.ident = groupid
-                    group.Name = fields.get("pykotaGroupName", [databaseToUnicode(groupname)])[0] 
-                    group.LimitBy = fields.get("pykotaLimitBy", ["quota"])[0]
+                    group.Name = fields.get("pykotaGroupName", [groupname])[0] 
+                    group.LimitBy = databaseToUnicode(fields.get("pykotaLimitBy", ["quota"])[0])
                     group.Description = databaseToUnicode(fields.get("description", [""])[0]) 
                     group.AccountBalance = 0.0
@@ -921,5 +921,5 @@
         newfields = {
                        "pykotaUserName" : uname,
-                       "pykotaLimitBy" : (user.LimitBy or "quota"),
+                       "pykotaLimitBy" : unicodeToDatabase(user.LimitBy or u"quota"),
                        "description" : unicodeToDatabase(user.Description or ""),
                        self.info["usermail"] : user.Email or "",
@@ -996,5 +996,5 @@
         newfields = { 
                       "pykotaGroupName" : gname,
-                      "pykotaLimitBy" : (group.LimitBy or "quota"),
+                      "pykotaLimitBy" : unicodeToDatabase(group.LimitBy or u"quota"),
                       "description" : unicodeToDatabase(group.Description or "")
                     } 
@@ -1127,5 +1127,5 @@
         """Saves the user to the database in a single operation."""
         newfields = {
-                       "pykotaLimitBy" : (user.LimitBy or "quota"),
+                       "pykotaLimitBy" : unicodeToDatabase(user.LimitBy or u"quota"),
                        "description" : unicodeToDatabase(user.Description or ""), 
                        self.info["usermail"] : user.Email or "",
@@ -1142,5 +1142,5 @@
         """Saves the group to the database in a single operation."""
         newfields = {
-                       "pykotaLimitBy" : (group.LimitBy or "quota"),
+                       "pykotaLimitBy" : unicodeToDatabase(group.LimitBy or u"quota"),
                        "description" : unicodeToDatabase(group.Description or ""), 
                     }   
