Permalink
Browse files

Modernized the project setup

  • Loading branch information...
1 parent 47921d3 commit 31205552d7bcb221ca3767053dc907eb9c001604 @rosarior committed Mar 10, 2011
Showing with 87 additions and 60 deletions.
  1. +79 −52 settings.py
  2. +8 −8 urls.py
View
@@ -1,36 +1,46 @@
# Django project settings.
# FLAGS
-
-PROJECT_TITLE = 'Descartes'
-
-DEBUG = False
-TEMPLATE_DEBUG = DEBUG
-DEBUG_APPS_DJANGO_EXTENSIONS = False
-DEVELOPMENT = False
-SERVE_STATIC_CONTENT = True
-
import os
-PROJECT_ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), "./"))
-
import sys
+
+PROJECT_ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), "./"))
sys.path.append(os.path.join(PROJECT_ROOT, 'modules'))
sys.path.append(os.path.join(PROJECT_ROOT, 'apps'))
sys.path.append(os.path.join(PROJECT_ROOT, 'customization_apps'))
sys.path.append(os.path.join(PROJECT_ROOT, 'shared_apps'))
sys.path.append(os.path.join(PROJECT_ROOT, '3rd_party_apps'))
+
+PROJECT_NAME = 'descartes'
+PROJECT_TITLE = 'Descartes'
+
+#DEBUG = False
+#TEMPLATE_DEBUG = DEBUG
+#DEBUG_APPS_DJANGO_EXTENSIONS = False
+#DEVELOPMENT = False
+#SERVE_STATIC_CONTENT = True
+
+DEBUG = False
+DEVELOPMENT = False
+TEMPLATE_DEBUG = True
+
+
ADMINS = (
# ('Your Name', 'your_email@domain.com'),
)
MANAGERS = ADMINS
-DATABASE_ENGINE = 'sqlite3' # 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
-DATABASE_NAME = PROJECT_TITLE + '.sqlite' # Or path to database file if using sqlite3.
-DATABASE_USER = '' # Not used with sqlite3.
-DATABASE_PASSWORD = '' # Not used with sqlite3.
-DATABASE_HOST = '' # Set to empty string for localhost. Not used with sqlite3.
-DATABASE_PORT = '' # Set to empty string for default. Not used with sqlite3.
+DATABASES = {
+ 'default': {
+ 'ENGINE': 'django.db.backends.sqlite3', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
+ 'NAME': os.path.join(PROJECT_ROOT, '%s.sqlite' % PROJECT_NAME), # Or path to database file if using sqlite3.
+ 'USER': '', # Not used with sqlite3.
+ 'PASSWORD': '', # Not used with sqlite3.
+ 'HOST': '', # Set to empty string for localhost. Not used with sqlite3.
+ 'PORT': '', # Set to empty string for default. Not used with sqlite3.
+ }
+}
# Local time zone for this installation. Choices can be found here:
# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
@@ -58,28 +68,33 @@
# to load the internationalization machinery.
USE_I18N = True
+# If you set this to False, Django will not format dates, numbers and
+# calendars according to the current locale
+USE_L10N = True
+
# Absolute path to the directory that holds media.
# Example: "/home/media/media.lawrence.com/"
MEDIA_ROOT = os.path.join(PROJECT_ROOT, 'site_media')
# URL that handles the media served from MEDIA_ROOT. Make sure to use a
# trailing slash if there is a path component (optional in other cases).
# Examples: "http://media.lawrence.com", "http://example.com/media/"
-MEDIA_URL = '/site_media/'
+MEDIA_URL = '/%s-site_media/' % PROJECT_NAME
# URL prefix for admin media -- CSS, JavaScript and images. Make sure to use a
# trailing slash.
# Examples: "http://foo.com/media/", "/media/".
-ADMIN_MEDIA_PREFIX = MEDIA_URL + 'admin_media/'
+ADMIN_MEDIA_PREFIX = MEDIA_URL + 'grappelli/'
# Make this unique, and don't share it with anybody.
SECRET_KEY = '@mff4*!u6*nc5+0pmkvcu#$&n1mq=n=+mb6g%2!ivyj3_m_g-1'
# List of callables that know how to import templates from various sources.
TEMPLATE_LOADERS = (
- 'django.template.loaders.filesystem.load_template_source',
- 'django.template.loaders.app_directories.load_template_source',
-# 'django.template.loaders.eggs.load_template_source',
+ ('django.template.loaders.cached.Loader', (
+ 'django.template.loaders.filesystem.Loader',
+ 'django.template.loaders.app_directories.Loader',
+ )),
)
MIDDLEWARE_CLASSES = (
@@ -105,60 +120,72 @@
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.admin',
+ 'django.contrib.humanize',
'reports',
- 'wsgi',
'common',
- 'django.contrib.humanize',
- 'tornado_app',
)
-CUSTOMIZATION_APPS = ()
-
-
-try:
- import ldap_groups
- import ldap
- INSTALLED_APPS += ('ldap_groups',)
-except ImportError:
- pass
-
+
TEMPLATE_CONTEXT_PROCESSORS = (
- "django.core.context_processors.auth",
- "django.core.context_processors.i18n",
- "django.core.context_processors.media",
+ 'django.core.context_processors.auth',
+ 'django.core.context_processors.i18n',
+ 'django.core.context_processors.media',
'django.core.context_processors.request',
+# 'grappelli.context_processors.admin_template_path',
)
-
-LOGIN_URL = '/login/'
-
+#===== Configuration options ===============
+#--------- Grappelli ----------------
+#GRAPPELLI_ADMIN_TITLE = PROJECT_TITLE
GRAPPELLI_ADMIN_TITLE = PROJECT_TITLE
-
+#--------- Django -------------------
+LOGIN_URL = '/login/'
+LOGIN_REDIRECT_URL = '/'
+#------------------------------------
SOURCE_DATABASE_ENGINE = 'sqlite3' # 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
-SOURCE_DATABASE_NAME = PROJECT_TITLE + '.sqlite' # Or path to database file if using sqlite3.
+SOURCE_DATABASE_NAME = PROJECT_NAME + '.sqlite' # Or path to database file if using sqlite3.
SOURCE_DATABASE_USER = '' # Not used with sqlite3.
SOURCE_DATABASE_PASSWORD = '' # Not used with sqlite3.
SOURCE_DATABASE_HOST = '' # Set to empty string for localhost. Not used with sqlite3.
SOURCE_DATABASE_PORT = ''
try:
from settings_local import *
- try:
- INSTALLED_APPS += CUSTOMIZATION_APPS
- except:
- pass
except ImportError:
pass
- #print u"No file 'settings_local.py' found."
-
+
if DEVELOPMENT:
+ INTERNAL_IPS = ('127.0.0.1',)
+
+ TEMPLATE_LOADERS = (
+ 'django.template.loaders.filesystem.Loader',
+ 'django.template.loaders.app_directories.Loader',
+ )
+ try:
+ import rosetta
+ INSTALLED_APPS += ('rosetta',)
+ except ImportError:
+ #print 'rosetta is not installed'
+ pass
+
try:
import django_extensions
- INSTALLED_APPS += ('django_extensions',)
+ INSTALLED_APPS +=('django_extensions',)
except ImportError:
+ #print 'django_extensions is not installed'
pass
try:
- import rosetta
- INSTALLED_APPS += ('rosetta',)
+ import debug_toolbar
+ #INSTALLED_APPS.append('debug_toolbar')
except ImportError:
+ #print 'debug_toolbar is not installed'
pass
+
+ TEMPLATE_CONTEXT_PROCESSORS += ('django.core.context_processors.debug',)
+
+ WSGI_AUTO_RELOAD = True
+ if 'debug_toolbar' in INSTALLED_APPS:
+ MIDDLEWARE_CLASSES.append('debug_toolbar.middleware.DebugToolbarMiddleware')
+ DEBUG_TOOLBAR_CONFIG={
+ 'INTERCEPT_REDIRECTS' : False,
+ }
View
@@ -38,23 +38,23 @@
(r'^favicon\.ico$', 'django.views.generic.simple.redirect_to', {'url': '%simages/favicon.ico' % settings.MEDIA_URL}),
)
-for capp in getattr(settings, 'CUSTOMIZATION_APPS', []):
- exec "urlpatterns += patterns('', (r'^customization/%s/', include('%s.urls', namespace='%s')), )" % (capp, capp, capp)
+#for capp in getattr(settings, 'CUSTOMIZATION_APPS', []):
+# exec "urlpatterns += patterns('', (r'^customization/%s/', include('%s.urls', namespace='%s')), )" % (capp, capp, capp)
if 'ldap_groups' in settings.INSTALLED_APPS:
urlpatterns += patterns('', (r'^ldap/', include('ldap_groups.urls')),)
if 'replicate' in settings.INSTALLED_APPS:
urlpatterns += patterns('', (r'^replicate/', include('replicate.urls')),)
-if settings.SERVE_STATIC_CONTENT:
+if settings.DEVELOPMENT:
urlpatterns += patterns('',
- (r'^site_media/(?P<path>.*)$', 'django.views.static.serve', {'document_root': settings.MEDIA_ROOT, 'show_indexes': True}),
+ (r'^%s-site_media/(?P<path>.*)$' % settings.PROJECT_NAME,
+ 'django.views.static.serve',
+ {'document_root':'site_media', 'show_indexes':True}),
)
-if settings.DEVELOPMENT:
if 'rosetta' in settings.INSTALLED_APPS:
urlpatterns += patterns('',
- url(r'^rosetta/', include('rosetta.urls')),
- )
-
+ url(r'^rosetta/', include('rosetta.urls'), name='rosetta'),
+ )

0 comments on commit 3120555

Please sign in to comment.