diff options
author | Jason Gerard DeRose <jderose@redhat.com> | 2008-11-12 00:46:04 -0700 |
---|---|---|
committer | Jason Gerard DeRose <jderose@redhat.com> | 2008-11-12 00:46:04 -0700 |
commit | 014af24731ff39520a9635694ed99dc9d09669c9 (patch) | |
tree | 3e861a7ba9f8ba9d07033fad6827920dfbc46c49 /ipalib/plugins/f_misc.py | |
parent | f3869d7b24f65ca04494ff756e092d7aedd67a5c (diff) | |
download | freeipa.git-014af24731ff39520a9635694ed99dc9d09669c9.tar.gz freeipa.git-014af24731ff39520a9635694ed99dc9d09669c9.tar.xz freeipa.git-014af24731ff39520a9635694ed99dc9d09669c9.zip |
Changed calling signature of output_for_cli(); started work on 'textui' backend plugin
Diffstat (limited to 'ipalib/plugins/f_misc.py')
-rw-r--r-- | ipalib/plugins/f_misc.py | 48 |
1 files changed, 15 insertions, 33 deletions
diff --git a/ipalib/plugins/f_misc.py b/ipalib/plugins/f_misc.py index ff8569b1..055e54d7 100644 --- a/ipalib/plugins/f_misc.py +++ b/ipalib/plugins/f_misc.py @@ -24,22 +24,11 @@ Misc frontend plugins. from ipalib import api, Command, Param, Bool -class env_and_context(Command): - """ - Base class for `env` and `context` commands. - """ - - def run(self, **kw): - if kw.get('server', False) and not self.api.env.in_server: - return self.forward() - return self.execute() - - def output_for_cli(self, ret): - for (key, value) in ret: - print '%s = %r' % (key, value) - - -class env(env_and_context): +# FIXME: We should not let env return anything in_server +# when mode == 'production'. This would allow an attacker to see the +# configuration of the server, potentially revealing compromising +# information. However, it's damn handy for testing/debugging. +class env(Command): """Show environment variables""" takes_options = ( @@ -48,26 +37,19 @@ class env(env_and_context): ), ) + def run(self, **kw): + if kw.get('server', False) and not self.api.env.in_server: + return self.forward() + return self.execute() + def execute(self): return tuple( (key, self.api.env[key]) for key in self.api.env ) -api.register(env) - - -class context(env_and_context): - """Show request context""" - - takes_options = ( - Param('server?', type=Bool(), default=False, - doc='Show request context in server', - ), - ) - - def execute(self): - return [ - (key, self.api.context[key]) for key in self.api.Context - ] + def output_for_cli(self, textui, result, **kw): + textui.print_name(self.name) + textui.print_keyval(result) + textui.print_count(result, '%d variable', '%d variables') -api.register(context) +api.register(env) |