[Patchew-devel] [PATCH 1/1] debug: Enable debug toolbar for superuser in production deploy

Fam Zheng famz at redhat.com
Tue Oct 30 09:57:18 UTC 2018


On Tue, 10/23 16:17, Paolo Bonzini wrote:
> 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. :)

Sounds good, I'll tweak it and repost.

> 
> patchew.org is very slow, not sure why.  I wonder if just strace or top
> can actually provide a clue...

Yeah, let me find some time to work on the performance in the coming month.

Fam

> 
> Paolo




More information about the Patchew-devel mailing list