Django

Code

Changeset 985

Show
Ignore:
Timestamp:
10/20/05 18:16:45 (3 years ago)
Author:
adrian
Message:

Fixed #663 -- app_directories template loader no longer assumes a dot in the app name. Thanks, Sune

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/trunk/django/core/template/loaders/app_directories.py

    r892 r985  
    22 
    33from django.conf.settings import INSTALLED_APPS, TEMPLATE_FILE_EXTENSION 
     4from django.core.exceptions import ImproperlyConfigured 
    45from django.core.template import TemplateDoesNotExist 
    56import os 
     
    910for app in INSTALLED_APPS: 
    1011    i = app.rfind('.') 
    11     m, a = app[:i], app[i+1:] 
    12     mod = getattr(__import__(m, '', '', [a]), a) 
     12    if i == -1: 
     13        m, a = app, None 
     14    else: 
     15        m, a = app[:i], app[i+1:] 
     16    try: 
     17        if a is None: 
     18            mod = __import__(m, '', '', []) 
     19        else: 
     20            mod = getattr(__import__(m, '', '', [a]), a) 
     21    except ImportError, e: 
     22        raise ImproperlyConfigured, 'ImportError %s: %s' % (app, e.args[0]) 
    1323    template_dir = os.path.join(os.path.dirname(mod.__file__), 'templates') 
    1424    if os.path.isdir(template_dir):