diff options
author | Michael DeHaan <mdehaan@redhat.com> | 2007-12-05 11:46:38 -0500 |
---|---|---|
committer | Michael DeHaan <mdehaan@redhat.com> | 2007-12-05 11:46:38 -0500 |
commit | 762de2e043b967bdf0bdc1be8189ab21b055a808 (patch) | |
tree | 38d29d16c66bcc5ae7a8c65b21725b8fa2a11a88 /scripts | |
parent | 58cae26af9b3a868041b52fc0dde6047faff73a3 (diff) | |
download | third_party-cobbler-762de2e043b967bdf0bdc1be8189ab21b055a808.tar.gz third_party-cobbler-762de2e043b967bdf0bdc1be8189ab21b055a808.tar.xz third_party-cobbler-762de2e043b967bdf0bdc1be8189ab21b055a808.zip |
mod_python version of webui now operational at http://server/cobbler/web with pluggable authn/authz and using same tokens through entire communication chain. Should probably implement a session logout though.
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/index.py | 59 |
1 files changed, 37 insertions, 22 deletions
diff --git a/scripts/index.py b/scripts/index.py index fc528df..c5ff4c0 100755 --- a/scripts/index.py +++ b/scripts/index.py @@ -1,6 +1,5 @@ """ -mod_python gateway to all interesting cobbler web and web service -functions. +mod_python gateway to all interesting cobbler web functions Copyright 2007, Red Hat, Inc Michael DeHaan <mdehaan@redhat.com> @@ -13,12 +12,13 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. """ -# still TODO: -# serve up Web UI through this interface, via tokens in headers - from mod_python import apache from mod_python import Session +from mod_python import util + import xmlrpclib +import cgi +from cobbler.webui import CobblerWeb XMLRPC_SERVER = "http://127.0.0.1/cobbler_api_rw" @@ -58,36 +58,51 @@ def __get_session(req): #====================================================== -def index(req): +def handler(req): """ Right now, index serves everything. Hitting this URL means we've already cleared authn/authz but we still need to use the token for all remote requests. - - FIXME: deal with query strings and defer to CobblerWeb.py """ my_user = __get_user(req) my_uri = req.uri - sess = __get_session(req) token = sess['cobbler_token'] - return "it seems to be all good: %s" % token - -#====================================================== - -def hello(req): - - """ - This is just another example for the publisher handler. - """ - - user = __get_user(req) - path = req.uri - return "We are in hello(%s)" % path + # needed? + req.add_common_vars() + + # process form and qs data, if any + fs = util.FieldStorage(req) + form = {} + for x in fs.keys(): + form[x] = str(fs.get(x,'default')) + + # instantiate a CobblerWeb object + cw = CobblerWeb.CobblerWeb( + token = token, + base_url = "/cobbler/web/", + server = "http://127.0.0.1/cobbler_api_rw" + ) + + # check for a valid path/mode + # handle invalid paths gracefully + mode = form.get('mode','index') + if mode in cw.modes(): + func = getattr( cw, mode ) + content = func( **form ) + else: + func = getattr( cw, 'error_page' ) + content = func( "Invalid Mode: \"%s\"" % mode ) + + # apache.log_error("%s:%s ... %s" % (my_user, my_uri, str(form))) + req.content_type = "text/html" + req.write(content) + + return apache.OK #====================================================== |