Changeset 1240 for pykota/trunk/pykota/storages/ldapstorage.py
- Timestamp:
- 12/27/03 17:49:25 (20 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
pykota/trunk/pykota/storages/ldapstorage.py
r1228 r1240 22 22 # 23 23 # $Log$ 24 # Revision 1.41 2003/12/27 16:49:25 uid67467 25 # Should be ok now. 26 # 24 27 # Revision 1.40 2003/11/29 22:02:14 jalet 25 28 # Don't try to retrieve the user print quota information if current printer … … 166 169 # 167 170 171 import types 168 172 import time 169 173 import md5 … … 211 215 return md5.md5("%s" % time.time()).hexdigest() 212 216 217 def normalizeFields(self, fields) : 218 """Ensure all items are lists.""" 219 for (k, v) in fields.items() : 220 if type(v) not in (types.TupleType, types.ListType) : 221 if not v : 222 del fields[k] 223 else : 224 fields[k] = [ v ] 225 return fields 226 213 227 def beginTransaction(self) : 214 228 """Starts a transaction.""" … … 237 251 def doAdd(self, dn, fields) : 238 252 """Adds an entry in the LDAP directory.""" 253 fields = self.normalizeFields(fields) 239 254 try : 240 255 self.tool.logdebug("QUERY : ADD(%s, %s)" % (dn, str(fields))) … … 255 270 def doModify(self, dn, fields, ignoreold=1) : 256 271 """Modifies an entry in the LDAP directory.""" 272 fields = self.normalizeFields(fields) 257 273 try : 258 274 oldentry = self.doSearch("objectClass=*", base=dn, scope=ldap.SCOPE_BASE) … … 545 561 return groupsandquotas 546 562 563 def getParentPrinters(self, printer) : 564 """Get all the printer groups this printer is a member of.""" 565 pgroups = [] 566 result = self.doSearch("(&(objectClass=pykotaPrinter)(uniqueMember=%s))" % printer.ident, ["pykotaPrinterName"], base=self.info["printerbase"]) 567 if result : 568 for (printerid, fields) in result : 569 parentprinter = self.getPrinter(fields.get("pykotaPrinterName")[0]) 570 if parentprinter.Exists : 571 pgroups.append(parentprinter) 572 return pgroups 573 547 574 def addPrinter(self, printername) : 548 575 """Adds a printer to the quota storage, returns it.""" … … 679 706 """Sets the date limit permanently for a user print quota.""" 680 707 fields = { 681 "pykotaDateLimit" : "%04i-%02i-%02i %02i:%02i:%02i" % (datelimit.year, datelimit.month, datelimit.day, datelimit.hour, datelimit.minute, datelimit.second),708 "pykotaDateLimit" : datelimit, 682 709 } 683 710 return self.doModify(userpquota.ident, fields) … … 686 713 """Sets the date limit permanently for a group print quota.""" 687 714 fields = { 688 "pykotaDateLimit" : "%04i-%02i-%02i %02i:%02i:%02i" % (datelimit.year, datelimit.month, datelimit.day, datelimit.hour, datelimit.minute, datelimit.second),715 "pykotaDateLimit" : datelimit, 689 716 } 690 717 return self.doModify(grouppquota.ident, fields)