diff options
author | Nathaniel McCallum <npmccallum@redhat.com> | 2013-10-01 13:57:24 -0400 |
---|---|---|
committer | Petr Viktorin <pviktori@redhat.com> | 2013-10-08 16:46:20 +0200 |
commit | e05dfbd8b4b4e040266ecfba579bcd64e22b342b (patch) | |
tree | f737217391030c89a8e37e6f1de412dd29ea4c8b /ipalib/crud.py | |
parent | b54cdab33d14d5eb47af7da2bdb84ade6a06abba (diff) | |
download | freeipa-e05dfbd8b4b4e040266ecfba579bcd64e22b342b.tar.gz freeipa-e05dfbd8b4b4e040266ecfba579bcd64e22b342b.tar.xz freeipa-e05dfbd8b4b4e040266ecfba579bcd64e22b342b.zip |
Add optional_create flag
Diffstat (limited to 'ipalib/crud.py')
-rw-r--r-- | ipalib/crud.py | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/ipalib/crud.py b/ipalib/crud.py index 72ea142da..cd244156e 100644 --- a/ipalib/crud.py +++ b/ipalib/crud.py @@ -133,16 +133,21 @@ class Create(Method): has_output = output.standard_entry + def __clone(self, param, **kw): + if 'optional_create' in param.flags: + kw['required'] = False + return param.clone(**kw) if kw else param + def get_args(self): if self.obj.primary_key: - yield self.obj.primary_key.clone(attribute=True) + yield self.__clone(self.obj.primary_key, attribute=True) for arg in super(Create, self).get_args(): - yield arg + yield self.__clone(arg) def get_options(self): if self.extra_options_first: for option in super(Create, self).get_options(): - yield option + yield self.__clone(option) for option in self.obj.params_minus(self.args): attribute = 'virtual_attribute' not in option.flags if 'no_create' in option.flags: @@ -153,10 +158,10 @@ class Create(Method): autofill=False, alwaysask=True ) else: - yield option.clone(attribute=attribute) + yield self.__clone(option, attribute=attribute) if not self.extra_options_first: for option in super(Create, self).get_options(): - yield option + yield self.__clone(option) class PKQuery(Method): |