diff options
-rw-r--r-- | ipalib/crud.py | 10 | ||||
-rw-r--r-- | ipalib/frontend.py | 15 |
2 files changed, 20 insertions, 5 deletions
diff --git a/ipalib/crud.py b/ipalib/crud.py index a522ad84e..990fc39bc 100644 --- a/ipalib/crud.py +++ b/ipalib/crud.py @@ -78,14 +78,14 @@ class Create(frontend.Method): """ def get_args(self): - yield self.obj.primary_key + yield self.obj.primary_key.clone(attribute=True) def get_options(self): if self.extra_options_first: for option in super(Create, self).get_options(): yield option for option in self.obj.params_minus(self.args): - yield option + yield option.clone(attribute=True) if not self.extra_options_first: for option in super(Create, self).get_options(): yield option @@ -97,7 +97,7 @@ class PKQuery(frontend.Method): """ def get_args(self): - yield self.obj.primary_key.clone(query=True) + yield self.obj.primary_key.clone(attribute=True, query=True) @@ -117,7 +117,7 @@ class Update(PKQuery): for option in super(Update, self).get_options(): yield option for option in self.obj.params_minus_pk(): - yield option.clone(required=False) + yield option.clone(attribute=True, required=False) if not self.extra_options_first: for option in super(Update, self).get_options(): yield option @@ -141,7 +141,7 @@ class Search(frontend.Method): for option in super(Search, self).get_options(): yield option for option in self.obj.params_minus(self.args): - yield option.clone(query=True, required=False) + yield option.clone(attribute=True, query=True, required=False) if not self.extra_options_first: for option in super(Search, self).get_options(): yield option diff --git a/ipalib/frontend.py b/ipalib/frontend.py index 54f7c87a0..db045fe67 100644 --- a/ipalib/frontend.py +++ b/ipalib/frontend.py @@ -176,6 +176,21 @@ class Command(plugable.Plugin): if name in options: yield (name, options[name]) + def args_options_2_entry(self, *args, **options): + """ + Creates a LDAP entry from attributes in args and options. + """ + kw = self.args_options_2_params(*args, **options) + return dict(self.__attributes_2_entry(kw)) + + def __attributes_2_entry(self, kw): + for name in self.params: + if self.params[name].attribute and name in kw: + if type(kw[name]) is tuple: + yield (name, [str(value) for value in kw[name]]) + else: + yield (name, str(kw[name])) + def params_2_args_options(self, **params): """ Split params into (args, options). |