summaryrefslogtreecommitdiffstats
path: root/ipalib/crud.py
diff options
context:
space:
mode:
authorJason Gerard DeRose <jderose@redhat.com>2009-01-21 17:19:39 -0700
committerRob Crittenden <rcritten@redhat.com>2009-02-03 15:28:59 -0500
commit4febb4dd1417de8961b2ab092b0c530ca088b72a (patch)
tree419789e208d36b2332e6eb274e61365db19ccb52 /ipalib/crud.py
parent6e53d03c69581982d341f591bfc3a35ec7f324d9 (diff)
downloadfreeipa-4febb4dd1417de8961b2ab092b0c530ca088b72a.tar.gz
freeipa-4febb4dd1417de8961b2ab092b0c530ca088b72a.tar.xz
freeipa-4febb4dd1417de8961b2ab092b0c530ca088b72a.zip
Started roughing out new crud base classes
Diffstat (limited to 'ipalib/crud.py')
-rw-r--r--ipalib/crud.py49
1 files changed, 49 insertions, 0 deletions
diff --git a/ipalib/crud.py b/ipalib/crud.py
index 345fc2700..bf33b7ab4 100644
--- a/ipalib/crud.py
+++ b/ipalib/crud.py
@@ -73,6 +73,55 @@ class Find(frontend.Method):
yield option
+class Create(frontend.Method):
+ """
+ Create a new entry.
+ """
+
+
+class PKQuery(frontend.Method):
+ """
+ Base class for `Retrieve`, `Update`, and `Delete`.
+ """
+
+ def get_args(self):
+ yield self.obj.primary_key.clone(query=True, multivalue=True)
+
+
+class Retrieve(PKQuery):
+ """
+ Retrieve an entry by its primary key.
+ """
+
+
+class Update(PKQuery):
+ """
+ Update one or more attributes on an entry.
+ """
+
+ def get_options(self):
+ if self.extra_options_first:
+ for option in super(Update, self).get_options():
+ yield option
+ for option in self.obj.params_minus_pk():
+ yield option.clone(required=False)
+ if not self.extra_options_first:
+ for option in super(Update, self).get_options():
+ yield option
+
+
+class Delete(PKQuery):
+ """
+ Delete one or more entries.
+ """
+
+
+class Search(frontend.Method):
+ """
+ Retrieve all entries that match a given search criteria.
+ """
+
+
class CrudBackend(backend.Backend):
"""
Base class defining generic CRUD backend API.