Fixed #10526 -- More fixes when specifying installed apps using "foo.*".

This adds a case that was missed in r9925: underscore handling.

Backport of r10078 from trunk.

git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.0.X@10079 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Malcolm Tredinnick 2009-03-18 01:08:34 +00:00
parent 75b286798f
commit 39c450cc6d
6 changed files with 4 additions and 5 deletions

View File

@ -7,6 +7,7 @@ a list of all possible variables.
""" """
import os import os
import re
import time # Needed for Windows import time # Needed for Windows
from django.conf import global_settings from django.conf import global_settings
@ -91,8 +92,9 @@ class Settings(object):
appdir = os.path.dirname(__import__(app[:-2], {}, {}, ['']).__file__) appdir = os.path.dirname(__import__(app[:-2], {}, {}, ['']).__file__)
app_subdirs = os.listdir(appdir) app_subdirs = os.listdir(appdir)
app_subdirs.sort() app_subdirs.sort()
name_pattern = re.compile(r'[a-zA-Z]\w*')
for d in app_subdirs: for d in app_subdirs:
if d.isalnum() and d[0].isalpha() and os.path.isdir(os.path.join(appdir, d)): if name_pattern.match(d) and os.path.isdir(os.path.join(appdir, d)):
new_installed_apps.append('%s.%s' % (app[:-2], d)) new_installed_apps.append('%s.%s' % (app[:-2], d))
else: else:
new_installed_apps.append(app) new_installed_apps.append(app)

View File

@ -1 +0,0 @@
# not empty to make SVN happy

View File

@ -1 +0,0 @@
# not empty to make SVN happy

View File

@ -1 +0,0 @@
# not empty to make SVN happy

View File

@ -14,7 +14,7 @@ Test the globbing of INSTALLED_APPS.
>>> settings = Settings('test_settings') >>> settings = Settings('test_settings')
>>> settings.INSTALLED_APPS >>> settings.INSTALLED_APPS
['parent.app', 'parent.app1'] ['parent.app', 'parent.app1', 'parent.app_2']
>>> sys.path = old_sys_path >>> sys.path = old_sys_path