summaryrefslogtreecommitdiffstats
path: root/ipalib/plugins/internal.py
diff options
context:
space:
mode:
authorAdam Young <ayoung@redhat.com>2010-11-17 22:15:09 -0500
committerEndi Sukma Dewata <edewata@redhat.com>2010-11-18 20:02:45 -0500
commit775fc23738d8a882bdd9cff9064b50594901e518 (patch)
tree35f841fa75bae9f4aef72ce80791aa49e2e62053 /ipalib/plugins/internal.py
parent5da8313b668340494f06afe6d3459f368948588f (diff)
downloadfreeipa-775fc23738d8a882bdd9cff9064b50594901e518.tar.gz
freeipa-775fc23738d8a882bdd9cff9064b50594901e518.tar.xz
freeipa-775fc23738d8a882bdd9cff9064b50594901e518.zip
batch init this batches together the calls to json_metadata, i18n_messages, and user-find [whoami] tostreamline the init process, and also allow us to add a call to enumerate the plugins.
Diffstat (limited to 'ipalib/plugins/internal.py')
-rw-r--r--ipalib/plugins/internal.py71
1 files changed, 41 insertions, 30 deletions
diff --git a/ipalib/plugins/internal.py b/ipalib/plugins/internal.py
index f1a16c987..708d829be 100644
--- a/ipalib/plugins/internal.py
+++ b/ipalib/plugins/internal.py
@@ -1,5 +1,6 @@
# Authors:
# Pavel Zuna <pzuna@redhat.com>
+# Adam YOung <ayoung@redhat.com>
#
# Copyright (c) 2010 Red Hat
# See file 'copying' for use and warranty information
@@ -35,6 +36,43 @@ class json_metadata(Command):
"""
INTERNAL = False
+
+ takes_args = (
+ Str('objname?',
+ doc=_('Name of object to export'),
+ ),
+ )
+
+ has_output = (
+ Output('metadata', dict, doc=_('Dict of JSON encoded IPA Objects')),
+ )
+
+ def execute(self, objname):
+
+ if objname and objname in self.api.Object:
+
+ meta = dict(
+ result=dict(
+ ((objname, json_serialize(self.api.Object[objname])), )
+ )
+ )
+ retval= dict([("metadata",meta), ("messages",dict())])
+
+ else:
+ meta=dict(
+ (o.name, json_serialize(o)) for o in self.api.Object()
+ )
+
+ retval= dict([("metadata",meta)])
+
+ return retval
+
+ def output_for_cli(self, textui, result, *args, **options):
+ print json.dumps(result, default=json_serialize)
+
+api.register(json_metadata)
+
+class i18n_messages(Command):
messages={
"login": {"header" :_("Logged In As")},
"button":{
@@ -67,41 +105,14 @@ class json_metadata(Command):
"Follow these directions</a> to configure your browser.")
}
}
-
- takes_args = (
- Str('objname?',
- doc=_('Name of object to export'),
- ),
- )
-
has_output = (
- Output('metadata', dict, doc=_('Dict of JSON encoded IPA Objects')),
Output('messages', dict, doc=_('Dict of I18N messages')),
)
-
- def execute(self, objname):
-
- if objname and objname in self.api.Object:
-
- meta = dict(
- result=dict(
- ((objname, json_serialize(self.api.Object[objname])), )
- )
- )
- retval= dict([("metadata",meta), ("messages",dict())])
-
- else:
- meta=dict(
- (o.name, json_serialize(o)) for o in self.api.Object()
- )
-
- retval= dict([("metadata",meta),
- ("messages",json_serialize(self.messages))])
-
- return retval
+ def execute(self):
+ return dict([("messages",json_serialize(self.messages))])
def output_for_cli(self, textui, result, *args, **options):
print json.dumps(result, default=json_serialize)
-api.register(json_metadata)
+api.register(i18n_messages)