summaryrefslogtreecommitdiffstats
path: root/ipalib/output.py
diff options
context:
space:
mode:
authorRob Crittenden <rcritten@redhat.com>2010-02-12 16:34:21 -0500
committerJason Gerard DeRose <jderose@redhat.com>2010-02-15 13:10:11 -0700
commit58746226d4b36bc40de91d4d1dd283e9faaff639 (patch)
tree11c4cd42b0285ff366c68274495cd1e9ee7fa7da /ipalib/output.py
parent99dcf9d4f97ac8bff112d6ccc36bb5b894fa5bcd (diff)
downloadfreeipa-58746226d4b36bc40de91d4d1dd283e9faaff639.tar.gz
freeipa-58746226d4b36bc40de91d4d1dd283e9faaff639.tar.xz
freeipa-58746226d4b36bc40de91d4d1dd283e9faaff639.zip
Use the Output tuple to determine the order of output
The attributes displayed is now dependant upon their definition in a Param. This enhances that, giving some level of control over how the result is displayed to the user. This also fixes displaying group membership, including failures of adding/removing entries. All tests pass now though there is still one problem. We need to return the dn as well. Once that is fixed we just need to comment out all the dn entries in the tests and they should once again pass.
Diffstat (limited to 'ipalib/output.py')
-rw-r--r--ipalib/output.py50
1 files changed, 44 insertions, 6 deletions
diff --git a/ipalib/output.py b/ipalib/output.py
index 425ff977c..757e7155e 100644
--- a/ipalib/output.py
+++ b/ipalib/output.py
@@ -29,18 +29,55 @@ from plugable import ReadOnly, lock
class Output(ReadOnly):
"""
Simple description of a member in the return value ``dict``.
+
+ This class controls both the type of object being returned by
+ a command as well as how the output will be displayed.
+
+ For example, this class defines two return results: an entry
+ and a value.
+
+ >>> from ipalib import crud, output
+ >>> class user(crud.Update):
+ ...
+ ... has_output = (
+ ... output.Entry('result'),
+ ... output.value,
+ ... )
+
+ The order of the values in has_output controls the order of output.
+ If you have values that you don't want to be printed then add
+ ``'no_display'`` to flags.
+
+ The difference between ``'no_dipslay`` and ``'no_output'`` is
+ that ``'no_output`` will prevent a Param value from being returned
+ at all. ``'no_display'`` will cause the API to return a value, it
+ simply won't be displayed to the user. This is so some things may
+ be returned that while not interesting to us, but may be to others.
+
+ >>> from ipalib import crud, output
+ >>> myvalue = output.Output('myvalue', unicode,
+ ... 'Do not print this value', flags=['no_display'],
+ ... )
+ >>> class user(crud.Update):
+ ...
+ ... has_output = (
+ ... output.Entry('result'),
+ ... myvalue,
+ ... )
"""
type = None
validate = None
doc = None
+ flags = []
- def __init__(self, name, type=None, doc=None):
+ def __init__(self, name, type=None, doc=None, flags=[]):
self.name = name
if type is not None:
self.type = type
if doc is not None:
self.doc = doc
+ self.flags = flags
lock(self)
def __repr__(self):
@@ -77,28 +114,29 @@ summary = Output('summary', (unicode, NoneType),
)
value = Output('value', unicode,
- "The primary_key value of the entry, e.g. 'jdoe' for a user"
+ "The primary_key value of the entry, e.g. 'jdoe' for a user",
+ flags=['no_display'],
)
-standard = (result, summary)
+standard = (summary, result)
standard_entry = (
+ summary,
Entry('result'),
value,
- summary,
)
standard_list_of_entries = (
+ summary,
ListOfEntries('result'),
Output('count', int, 'Number of entries returned'),
Output('truncated', bool, 'True if not all results were returned'),
- summary,
)
standard_delete = (
+ summary,
Output('result', bool, 'True means the operation was successful'),
value,
- summary,
)
standard_value = standard_delete