Permalink
Browse files

Added nephila's fixes and also added a default THEME_DIR value to pre…

…vent failure when PROJECT_DIR and PROJECT_HOME are both missing.
  • Loading branch information...
1 parent 20c99fd commit 6077171ac587f5e6e851b417bb7b99bedbcb3240 @growlf growlf committed Jul 16, 2012
Showing with 10 additions and 5 deletions.
  1. +10 −5 cms_themes/__init__.py
@@ -5,17 +5,22 @@
def init_themes():
if not hasattr(settings, 'THEMES_DIR'):
- THEMES_DIR = os.path.join(settings.PROJECT_DIR, 'themes')
+ if hasattr(settings, 'PROJECT_DIR'):
+ THEMES_DIR = os.path.join(settings.PROJECT_DIR, 'themes')
+ elif hasattr(settings, 'PROJECT_HOME'):
+ THEMES_DIR = os.path.join(settings.PROJECT_HOME, 'themes')
+ else:
+ THEMES_DIR = os.path.join(settings.MEDIA_ROOT, 'themes')
if not os.path.exists(THEMES_DIR):
os.makedirs(THEMES_DIR)
settings.STATICFILES_DIRS = (
- ('themes', os.path.join(settings.PROJECT_DIR, "themes")),
+ ('themes', THEMES_DIR),
) + settings.STATICFILES_DIRS
setattr(settings, 'THEMES_DIR', THEMES_DIR)
if not hasattr(settings, 'DEFAULT_CMS_TEMPLATES'):
setattr(settings, 'DEFAULT_CMS_TEMPLATES', settings.CMS_TEMPLATES)
if settings.THEMES_DIR not in settings.TEMPLATE_DIRS:
- settings.TEMPLATE_DIRS = settings.TEMPLATE_DIRS + (settings.THEMES_DIR,)
+ settings.TEMPLATE_DIRS = list(settings.TEMPLATE_DIRS) + [settings.THEMES_DIR,]
if not hasattr(settings, 'DEFAULT_TEMPLATE_DIRS'):
setattr(settings, 'DEFAULT_TEMPLATE_DIRS', settings.TEMPLATE_DIRS)
if not hasattr(settings, 'DEFAULT_STATICFILES_DIRS'):
@@ -49,8 +54,8 @@ def set_themes():
template_display = '%s (%s)' % (template.replace('_', ' ').title().split('.')[0], theme_dir)
theme_templates.append((template, template_display))
- setattr(settings, 'CMS_TEMPLATES', tuple(theme_templates) + settings.DEFAULT_CMS_TEMPLATES)
- setattr(settings, 'STATICFILES_DIRS', (settings.THEMES_DIR,) + settings.DEFAULT_STATICFILES_DIRS)
+ setattr(settings, 'CMS_TEMPLATES', list(theme_templates) + list(settings.DEFAULT_CMS_TEMPLATES))
+ setattr(settings, 'STATICFILES_DIRS', [settings.THEMES_DIR] + list(settings.DEFAULT_STATICFILES_DIRS))
try:
from django.conf import settings

0 comments on commit 6077171

Please sign in to comment.