diff options
-rw-r--r-- | ipalib/frontend.py | 9 | ||||
-rw-r--r-- | ipalib/plugable.py | 18 | ||||
-rw-r--r-- | ipalib/tests/test_plugable.py | 1 |
3 files changed, 20 insertions, 8 deletions
diff --git a/ipalib/frontend.py b/ipalib/frontend.py index bcd610a5..6c5f8c76 100644 --- a/ipalib/frontend.py +++ b/ipalib/frontend.py @@ -521,8 +521,13 @@ class Object(plugable.Plugin): takes_params = tuple() def __create_params(self): - for param in self.takes_params: - yield create_param(param) + props = self.properties.__todict__() + for spec in self.takes_params: + if type(spec) is str and spec.rstrip('?*+') in props: + yield props.pop(spec.rstrip('?*+')).param + else: + yield create_param(spec) + def set_api(self, api): super(Object, self).set_api(api) diff --git a/ipalib/plugable.py b/ipalib/plugable.py index cd130a19..e1d728d4 100644 --- a/ipalib/plugable.py +++ b/ipalib/plugable.py @@ -545,13 +545,13 @@ class NameSpace(ReadOnly): def __len__(self): """ - Returns the number of members. + Return the number of members. """ return len(self.__members) def __iter__(self): """ - Iterates through the member names. + Iterate through the member names. If this instance was created with ``sort=True``, the names will be in alphabetical order; otherwise the names will be in the same order as @@ -564,7 +564,7 @@ class NameSpace(ReadOnly): def __call__(self): """ - Iterates through the members. + Iterate through the members. If this instance was created with ``sort=True``, the members will be in alphabetical order by name; otherwise the members will be in the @@ -577,13 +577,13 @@ class NameSpace(ReadOnly): def __contains__(self, name): """ - Returns True if namespace has a member named ``name``. + Return True if namespace has a member named ``name``. """ return name in self.__map def __getitem__(self, spec): """ - Returns a member by name or index, or returns a slice of members. + Return a member by name or index, or returns a slice of members. :param spec: The name or index of a member, or a slice object. """ @@ -597,7 +597,7 @@ class NameSpace(ReadOnly): def __repr__(self): """ - Returns a pseudo-valid expression that could create this instance. + Return a pseudo-valid expression that could create this instance. """ return '%s(<%d members>, sort=%r)' % ( self.__class__.__name__, @@ -605,6 +605,12 @@ class NameSpace(ReadOnly): self.__sort, ) + def __todict__(self): + """ + Return a copy of the private dict mapping name to member. + """ + return dict(self.__map) + class Registrar(DictProxy): """ diff --git a/ipalib/tests/test_plugable.py b/ipalib/tests/test_plugable.py index 02d35cde..95d3825f 100644 --- a/ipalib/tests/test_plugable.py +++ b/ipalib/tests/test_plugable.py @@ -586,6 +586,7 @@ class test_NameSpace(ClassChecker): else: ordered = members names = tuple(m.name for m in ordered) + assert o.__todict__() == dict((o.name, o) for o in ordered) # Test __len__: assert len(o) == cnt |