On 10/06/2010 03:35 AM, Rob Crittenden wrote:
Pavel Zuna wrote:
takes_args defined in a baseldap subclass is now transformed into
positional arguments that go after primary keys. Before this patch,
takes_args in crud subclasses were ignored.

example:

--- snip ---

class user_something(LDAPRetrieve):
takes_args = (
Str('randomarg'),
)

--- snip ---

# ipa help something
Usage: ipa [global-options] user-something LOGIN RANDOMARG


Pavel

Nack, this breaks the pwpolicy plugin tests (though I'm not 100% sure
why). pwpolicy-del defines its own get_args(). I'm guessing it is
failing because the local get_args returns a string and the multivalue
stuff is expecting a list so pulling the string apart one character at a
time. If you run pwpolicy-del testpolicy it will fail with a not found
on 't' policy.

I think simply removing the get_args() from pwpolicy will fix it:

rob

Fixed version attached.

Pavel
>From dca00ce6a586ee91a0518e3473c49223f8e7cdf3 Mon Sep 17 00:00:00 2001
From: Pavel Zuna <pz...@redhat.com>
Date: Tue, 5 Oct 2010 14:33:27 -0400
Subject: [PATCH 1/3] Generate additional positional arguments for baseldap commands from takes_args.

---
 ipalib/plugins/baseldap.py |    8 ++++++++
 ipalib/plugins/pwpolicy.py |    4 +++-
 2 files changed, 11 insertions(+), 1 deletions(-)

diff --git a/ipalib/plugins/baseldap.py b/ipalib/plugins/baseldap.py
index f6b98e2..42d9017 100644
--- a/ipalib/plugins/baseldap.py
+++ b/ipalib/plugins/baseldap.py
@@ -240,6 +240,8 @@ class LDAPCreate(CallbackInterface, crud.Create):
             yield key
         if self.obj.primary_key:
             yield self.obj.primary_key.clone(attribute=True)
+        for arg in super(crud.Create, self).get_args():
+            yield arg
 
     def execute(self, *keys, **options):
         ldap = self.obj.backend
@@ -343,6 +345,8 @@ class LDAPQuery(CallbackInterface, crud.PKQuery):
             yield key
         if self.obj.primary_key:
             yield self.obj.primary_key.clone(attribute=True, query=True)
+        for arg in super(crud.PKQuery, self).get_args():
+            yield arg
 
 
 class LDAPMultiQuery(LDAPQuery):
@@ -356,6 +360,8 @@ class LDAPMultiQuery(LDAPQuery):
             yield self.obj.primary_key.clone(
                 attribute=True, query=True, multivalue=True
             )
+        for arg in super(crud.PKQuery, self).get_args():
+            yield arg
 
 
 class LDAPRetrieve(LDAPQuery):
@@ -881,6 +887,8 @@ class LDAPSearch(CallbackInterface, crud.Search):
         for key in self.obj.get_ancestor_primary_keys():
             yield key
         yield Str('criteria?')
+        for arg in super(crud.Search, self).get_args():
+            yield arg
 
     def get_options(self):
         for option in super(LDAPSearch, self).get_options():
diff --git a/ipalib/plugins/pwpolicy.py b/ipalib/plugins/pwpolicy.py
index dbbb471..cbfbf80 100644
--- a/ipalib/plugins/pwpolicy.py
+++ b/ipalib/plugins/pwpolicy.py
@@ -300,7 +300,9 @@ class pwpolicy_del(LDAPDelete):
     Delete a group password policy.
     """
     def get_args(self):
-        yield self.obj.primary_key.clone(attribute=True, required=True)
+        yield self.obj.primary_key.clone(
+            attribute=True, required=True, multivalue=True
+        )
 
     def post_callback(self, ldap, dn, *keys, **options):
         try:
-- 
1.7.1.1

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

Reply via email to