Opened 6 years ago

Last modified 6 years ago

#409 new defect

Django autoinstaller results in broken MIDDLEWARE

Reported by: achernya Owned by:
Priority: blocker Milestone:
Component: autoinstallers Keywords:
Cc:

Description

At some point, django.contrib.admin and django.contrib.admindocs got added to MIDDLEWARE in settigns.py. But they're not middleware; this blows up Django during the install process and later on when trying to do anything.

I investigated the autoinstaller, and we don't seem to be adding to middleware at all. We can work around this by removing it, but I'd like to figure out what the underlying problem is ASAP. adehnert, do you have any idea what could be causing this?

Change History (1)

comment:1 Changed 6 years ago by achernya

  • Component changed from default to autoinstallers

Oh, great. It is in fact our autoinstaller, a normal django-admin startproject produces

INSTALLED_APPS·=·($
····'django.contrib.admin',$
····'django.contrib.auth',$
····'django.contrib.contenttypes',$
····'django.contrib.sessions',$
····'django.contrib.messages',$
····'django.contrib.staticfiles',$
)$
$
MIDDLEWARE_CLASSES·=·($
····'django.contrib.sessions.middleware.SessionMiddleware',$
····'django.middleware.common.CommonMiddleware',$
····'django.middleware.csrf.CsrfViewMiddleware',$
····'django.contrib.auth.middleware.AuthenticationMiddleware',$
····'django.contrib.messages.middleware.MessageMiddleware',$
····'django.middleware.clickjacking.XFrameOptionsMiddleware',$
)$

The autoinstaller says

  } elsif (/^INSTALLED_APPS/) {
    print NEWSETTINGS "$_\n";
    while (<SETTINGS>) {
      if (/^\)/) {
        print NEWSETTINGS "    'django.contrib.admin',\n";
        print NEWSETTINGS "    'django.contrib.admindocs',\n";
      }
      print NEWSETTINGS $_;
    }

---that loop doesn't terminate early enough. It continues processing the rest of the file, resulting in the ^)$ being replaced. We probably need to add aprint NEWSETTINGS ")\n"; continue; to make it get out of that if. Can someone that knows more perl than I do verify?

Note: See TracTickets for help on using tickets.