From 92a150b4f11e18f29c9eb7719b9ff8a0d7759717 Mon Sep 17 00:00:00 2001 From: Jason Gerard DeRose Date: Thu, 29 Jan 2009 00:38:16 -0700 Subject: Some tweaks in user plugins, ported to new crud base classes --- ipalib/crud.py | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) (limited to 'ipalib/crud.py') 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): """ -- cgit