Ticket #583: settings-v3.patch

File settings-v3.patch, 1.6 KB (added by sune.kirkeby@…, 10 years ago)

Python 2.3 safe patch

  • django/conf/global_settings.py

     
    5454# Host for sending e-mail.
    5555EMAIL_HOST = 'localhost'
    5656
     57# Should templates/ directories in the INSTALLED_APPS module-directories
     58# be added to TEMPLATE_DIRS,
     59ADD_APP_TEMPLATE_DIRS = False
     60
    5761# List of locations of the template source files, in search order.
    5862TEMPLATE_DIRS = ()
    5963
  • django/conf/settings.py

     
    4444            setting_value = (setting_value,) # In case the user forgot the comma.
    4545        setattr(me, setting, setting_value)
    4646
     47# Add templates/ directories from INSTALLED_APPS to TEMPLATE_DIRS,
     48# [ Note -- There is a good reason i jump through these hoops, if the
     49# original TEMPLATE_DIRS setting was a list-instance, we should keep it
     50# that way. ]
     51if me.ADD_APP_TEMPLATE_DIRS:
     52    tds_type = type(me.TEMPLATE_DIRS)
     53    tds = list(me.TEMPLATE_DIRS)
     54    for app in me.INSTALLED_APPS:
     55        i = app.rfind('.')
     56        m, a = app[:i], app[i+1:]
     57        m = getattr(__import__(m, globals(), locals(), [a]), a)
     58        app_root = os.path.dirname(m.__file__)
     59        td = os.path.join(app_root, 'templates')
     60        if os.path.isdir(td):
     61            tds.append(td)
     62    me.TEMPLATE_DIRS = tds_type(tds)
     63
    4764# save DJANGO_SETTINGS_MODULE in case anyone in the future cares
    4865me.SETTINGS_MODULE = os.environ.get(ENVIRONMENT_VARIABLE, '')
    4966
Back to Top