[Patchew-devel] [PATCH 1/1] debug: Enable debug toolbar for superuser in production deploy
Paolo Bonzini
pbonzini at redhat.com
Tue Oct 23 14:17:02 UTC 2018
On 23/10/2018 16:01, Fam Zheng wrote:
> Signed-off-by: Fam Zheng <famz at redhat.com>
> ---
> patchew/settings.py | 12 +++++++++---
> 1 file changed, 9 insertions(+), 3 deletions(-)
>
> diff --git a/patchew/settings.py b/patchew/settings.py
> index 65a3b29..cea5187 100644
> --- a/patchew/settings.py
> +++ b/patchew/settings.py
> @@ -128,9 +128,8 @@ BLOB_DIR = os.path.join(DATA_DIR, "blob")
> if not os.path.isdir(BLOB_DIR):
> os.mkdir(BLOB_DIR)
>
> -if DEBUG:
> - INSTALLED_APPS += ['debug_toolbar']
> - MIDDLEWARE += ['debug_toolbar.middleware.DebugToolbarMiddleware']
> +INSTALLED_APPS += ['debug_toolbar']
> +MIDDLEWARE += ['debug_toolbar.middleware.DebugToolbarMiddleware']
>
> MEDIA_ROOT = os.path.join(DATA_DIR, "media")
> MEDIA_URL = "/media/"
> @@ -220,3 +219,10 @@ if not DEBUG:
> },
> },
> }
> +
> +def debug_toolbar_check(request):
> + return request.user.is_superuser
> +
> +DEBUG_TOOLBAR_CONFIG = {
> + 'SHOW_TOOLBAR_CALLBACK': debug_toolbar_check,
> +}
>
Great! But I would make it "DEBUG or request.user.is_staff" (i.e. users
that can access the admin) instead. That's because I'm not superuser on
patchew.org. :)
patchew.org is very slow, not sure why. I wonder if just strace or top
can actually provide a clue...
Paolo
More information about the Patchew-devel
mailing list