diff options
author | Jason Gerard DeRose <jderose@redhat.com> | 2009-01-29 00:38:16 -0700 |
---|---|---|
committer | Rob Crittenden <rcritten@redhat.com> | 2009-02-03 15:29:05 -0500 |
commit | 92a150b4f11e18f29c9eb7719b9ff8a0d7759717 (patch) | |
tree | 46ac46d2580c377e6bdebca539a44863d22071ae /ipalib/crud.py | |
parent | 0211c76cd0ce614b9c7510315dbadf5336667410 (diff) | |
download | freeipa-92a150b4f11e18f29c9eb7719b9ff8a0d7759717.tar.gz freeipa-92a150b4f11e18f29c9eb7719b9ff8a0d7759717.tar.xz freeipa-92a150b4f11e18f29c9eb7719b9ff8a0d7759717.zip |
Some tweaks in user plugins, ported to new crud base classes
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 5faa69ef..a522ad84 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): """ |