diff options
Diffstat (limited to 'ipalib/crud.py')
-rw-r--r-- | ipalib/crud.py | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/ipalib/crud.py b/ipalib/crud.py index 5faa69ef3..a522ad84e 100644 --- a/ipalib/crud.py +++ b/ipalib/crud.py @@ -21,8 +21,7 @@ Base classes for standard CRUD operations. """ -import backend, frontend, errors - +import backend, frontend class Add(frontend.Method): def get_args(self): @@ -78,6 +77,19 @@ class Create(frontend.Method): Create a new entry. """ + def get_args(self): + yield self.obj.primary_key + + 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 + if not self.extra_options_first: + for option in super(Create, self).get_options(): + yield option + class PKQuery(frontend.Method): """ @@ -88,6 +100,7 @@ class PKQuery(frontend.Method): yield self.obj.primary_key.clone(query=True) + class Retrieve(PKQuery): """ Retrieve an entry by its primary key. @@ -121,6 +134,18 @@ class Search(frontend.Method): Retrieve all entries that match a given search criteria. """ + takes_args = 'criteria?' + + def get_options(self): + if self.extra_options_first: + 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) + if not self.extra_options_first: + for option in super(Search, self).get_options(): + yield option + class CrudBackend(backend.Connectible): """ |