-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

When deleting multiple objects, the code tries to enforce that the
primary key is always iterable by doing:

keys = keys[:-1] + (keys[-1], )

But this doesn't work, the line only concatenates two tuples effectively
returning the original one. See the attached patch for a fix.

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org/

iEYEARECAAYFAk0PSOgACgkQHsardTLnvCWaYwCgxLGN09ZAjApMevLaQqlSM0hZ
NnIAoLFkL2o2eBbQhDyEEJ7URz9NkFvo
=Z2cP
-----END PGP SIGNATURE-----
From 0438ac08fbfbc6e06cded529b6021f3c5b5255fe Mon Sep 17 00:00:00 2001
From: Jakub Hrozek <jhro...@redhat.com>
Date: Tue, 14 Dec 2010 18:02:41 +0100
Subject: [PATCH] Make pkey always iterable when deleting

---
 ipalib/plugins/baseldap.py |    8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/ipalib/plugins/baseldap.py b/ipalib/plugins/baseldap.py
index 69682dc..3adf351 100644
--- a/ipalib/plugins/baseldap.py
+++ b/ipalib/plugins/baseldap.py
@@ -889,12 +889,14 @@ class LDAPDelete(LDAPMultiQuery):
             return result
 
         if not self.obj.primary_key or not isinstance(keys[-1], (list, tuple)):
-            keys = keys[:-1] + (keys[-1], )
+            pkeyiter = (keys[-1], )
+        else:
+            pkeyiter = keys[-1]
 
         deleted = []
         failed = []
         result = True
-        for pkey in keys[-1]:
+        for pkey in pkeyiter:
             try:
                 if not delete_entry(pkey):
                     result = False
@@ -905,7 +907,7 @@ class LDAPDelete(LDAPMultiQuery):
             else:
                 deleted.append(pkey)
 
-        if self.obj.primary_key and keys[-1] is not None:
+        if self.obj.primary_key and pkeyiter is not None:
             return dict(result=result, value=u','.join(deleted))
         return dict(result=result, value=u'')
 
-- 
1.7.3.3

Attachment: freeipa-jhrozek-028-pkey-iterable.patch.sig
Description: PGP signature

_______________________________________________
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel

Reply via email to