From e643f239816bae29e8206407db3d5eabdd2ea4b0 Mon Sep 17 00:00:00 2001 From: Joe Heck Date: Sun, 29 Jan 2012 10:57:02 -0800 Subject: doc updates --- keystone/cli.py | 2 +- keystone/middleware/core.py | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+), 1 deletion(-) (limited to 'keystone') diff --git a/keystone/cli.py b/keystone/cli.py index 0469ab3a..93e36205 100644 --- a/keystone/cli.py +++ b/keystone/cli.py @@ -24,7 +24,7 @@ config.register_cli_str('endpoint', config.register_cli_str('auth-token', default='$admin_token', #group='ks', - help='asdasd', + help='authorization token', conf=CONF) config.register_cli_bool('id-only', default=False, diff --git a/keystone/middleware/core.py b/keystone/middleware/core.py index 389c9bf0..305a7d44 100644 --- a/keystone/middleware/core.py +++ b/keystone/middleware/core.py @@ -1,6 +1,7 @@ # vim: tabstop=4 shiftwidth=4 softtabstop=4 import json +import webob from keystone import config from keystone.common import wsgi @@ -98,3 +99,40 @@ class JsonBodyMiddleware(wsgi.Middleware): params[k] = v request.environ[PARAMS_ENV] = params + + +class Debug(wsgi.Middleware): + """ + Middleware that produces stream debugging traces to the console (stdout) + for HTTP requests and responses flowing through it. + """ + + @webob.dec.wsgify + def __call__(self, req): + print ("*" * 40) + " REQUEST ENVIRON" + for key, value in req.environ.items(): + print key, "=", value + print + resp = req.get_response(self.application) + + print ("*" * 40) + " RESPONSE HEADERS" + for (key, value) in resp.headers.iteritems(): + print key, "=", value + print + + resp.app_iter = self.print_generator(resp.app_iter) + + return resp + + @staticmethod + def print_generator(app_iter): + """ + Iterator that prints the contents of a wrapper string iterator + when iterated. + """ + print ("*" * 40) + " BODY" + for part in app_iter: + sys.stdout.write(part) + sys.stdout.flush() + yield part + print -- cgit