Commit aea72a62 by David Ormsbee

matching settings2 to old settings -- fix template lookup

parent 2eedce01
Transitional for moving to new settings scheme. Transitional for moving to new settings scheme.
To use: To use:
django-admin runserver --settings=settings2.dev --pythonpath="." django-admin.py runserver --settings=settings2.dev --pythonpath="."
...@@ -67,10 +67,12 @@ MAKO_TEMPLATES = {} ...@@ -67,10 +67,12 @@ MAKO_TEMPLATES = {}
MAKO_TEMPLATES['course'] = [DATA_DIR] MAKO_TEMPLATES['course'] = [DATA_DIR]
MAKO_TEMPLATES['sections'] = [DATA_DIR / 'sections'] MAKO_TEMPLATES['sections'] = [DATA_DIR / 'sections']
MAKO_TEMPLATES['custom_tags'] = [DATA_DIR / 'custom_tags'] MAKO_TEMPLATES['custom_tags'] = [DATA_DIR / 'custom_tags']
MAKO_TEMPLATES['main'] = [ENV_ROOT / 'templates/'] MAKO_TEMPLATES['main'] = [PROJECT_ROOT / 'templates', DATA_DIR / 'info']
# FIXME: We're not checking this out in this location yet # FIXME: We're not checking this out in this location yet
TEXTBOOK_DIR = ENV_ROOT / "books" / "circuits_agarwal_lang" # TEXTBOOK_DIR = ENV_ROOT / "books" / "circuits_agarwal_lang" # What it should eventually be
TEXTBOOK_DIR = ENV_ROOT / "book_images"
# FIXME ???????? -- # FIXME ???????? --
# We should have separate S3 staged URLs in case we need to make changes to # We should have separate S3 staged URLs in case we need to make changes to
...@@ -88,7 +90,8 @@ STATIC_GRAB = False ...@@ -88,7 +90,8 @@ STATIC_GRAB = False
DEV_CONTENT = True DEV_CONTENT = True
# FIXME: Should we be doing this truncation? # FIXME: Should we be doing this truncation?
TRACK_MAX_EVENT = 5000 TRACK_MAX_EVENT = 10000
DEBUG_TRACK_LOG = False
############################### DJANGO BUILT-INS ############################### ############################### DJANGO BUILT-INS ###############################
# Change DEBUG/TEMPLATE_DEBUG in your environment settings files, not here # Change DEBUG/TEMPLATE_DEBUG in your environment settings files, not here
...@@ -119,23 +122,27 @@ STATIC_ROOT = ENV_ROOT / "staticfiles" # FIXME: Should this and uploads be moved ...@@ -119,23 +122,27 @@ STATIC_ROOT = ENV_ROOT / "staticfiles" # FIXME: Should this and uploads be moved
# FIXME: We should iterate through the courses we have, adding the static # FIXME: We should iterate through the courses we have, adding the static
# contents for each of them. (Right now we just use symlinks.) # contents for each of them. (Right now we just use symlinks.)
STATICFILES_DIRS = ( STATICFILES_DIRS = (
# FIXME: Need to add entries for book, data/images, etc. # FIXME: Need to add entries for book, data/images, etc.
# PROJECT_ROOT / "static", PROJECT_ROOT / "static",
ENV_ROOT / "static",
ASKBOT_ROOT / "askbot" / "skins", ASKBOT_ROOT / "askbot" / "skins",
# Something like this will probably need to be enabled when we're really doing
# multiple courses.
# ("circuits", DATA_DIR / "images"), # ("circuits", DATA_DIR / "images"),
# ("handouts", DATA_DIR / "handouts"), # ("handouts", DATA_DIR / "handouts"),
# ("subs", DATA_DIR / "subs"), # ("subs", DATA_DIR / "subs"),
# ("book", TEXTBOOK_DIR) # ("book", TEXTBOOK_DIR)
) )
# Templates # This is where Django Template lookup is defined.
TEMPLATE_DIRS = ( TEMPLATE_DIRS = (
ENV_ROOT / "templates", PROJECT_ROOT / "templates",
# PROJECT_ROOT / "templates", DATA_DIR / "templates",
# DATA_DIR / "problems",
) )
#'/Users/dave/Projects/mitx/mitx_all//data//templates', '/Users/dave/Projects/mitx/mitx_all//textbook/')
#path(u'/Users/dave/Projects/mitx/mitx_all/data/problems'))
TEMPLATE_CONTEXT_PROCESSORS = ( TEMPLATE_CONTEXT_PROCESSORS = (
'django.core.context_processors.request', 'django.core.context_processors.request',
'askbot.context.application_settings', 'askbot.context.application_settings',
...@@ -149,7 +156,7 @@ TEMPLATE_CONTEXT_PROCESSORS = ( ...@@ -149,7 +156,7 @@ TEMPLATE_CONTEXT_PROCESSORS = (
DEFAULT_FILE_STORAGE = 'django.core.files.storage.FileSystemStorage' DEFAULT_FILE_STORAGE = 'django.core.files.storage.FileSystemStorage'
MEDIA_ROOT = ENV_ROOT / "uploads" MEDIA_ROOT = ENV_ROOT / "uploads"
MEDIA_URL = "/discussion/upfiles/" MEDIA_URL = "/discussion/upfiles/"
FILE_UPLOAD_TEMP_DIR = os.path.join(os.path.dirname(__file__), 'tmp').replace('\\','/') FILE_UPLOAD_TEMP_DIR = ENV_ROOT / "uploads"
FILE_UPLOAD_HANDLERS = ( FILE_UPLOAD_HANDLERS = (
'django.core.files.uploadhandler.MemoryFileUploadHandler', 'django.core.files.uploadhandler.MemoryFileUploadHandler',
'django.core.files.uploadhandler.TemporaryFileUploadHandler', 'django.core.files.uploadhandler.TemporaryFileUploadHandler',
...@@ -166,13 +173,27 @@ USE_L10N = True ...@@ -166,13 +173,27 @@ USE_L10N = True
# logger. # logger.
pid = os.getpid() # So we can log which process is creating the log pid = os.getpid() # So we can log which process is creating the log
hostname = platform.node().split(".")[0] hostname = platform.node().split(".")[0]
LOG_DIR = "/tmp"
SYSLOG_ADDRESS = ('syslog.m.i4x.org', 514) SYSLOG_ADDRESS = ('syslog.m.i4x.org', 514)
TRACKING_LOG_FILE = LOG_DIR + "/tracking_{0}.log".format(pid)
handlers = ['console'] handlers = ['console']
# FIXME: re-enable syslogger later # FIXME: re-enable syslogger later
# if not DEBUG: # if not DEBUG:
# handlers.append('syslogger') # handlers.append('syslogger')
LOGGING_ENV = "dev" # override this in different environments
# def register_loggers(syslog_addr, tracking_log_dir, logging_env):
# pid = os.getpid() # So we can log which process is creating the log
# hostname = platform.node().split(".")[0]
# SYSLOG_ADDRESS = ('syslog.m.i4x.org', 514)
# TRACKING_LOG_FILE = LOG_DIR + "/tracking_{0}.log".format(pid)
#
# handlers = ['console']
LOGGING = { LOGGING = {
'version': 1, 'version': 1,
'disable_existing_loggers': True, 'disable_existing_loggers': True,
...@@ -181,7 +202,8 @@ LOGGING = { ...@@ -181,7 +202,8 @@ LOGGING = {
'format' : '%(asctime)s %(levelname)s %(process)d [%(name)s] %(filename)s:%(lineno)d - %(message)s', 'format' : '%(asctime)s %(levelname)s %(process)d [%(name)s] %(filename)s:%(lineno)d - %(message)s',
}, },
'syslog_format' : { 'syslog_format' : {
'format' : '[%(name)s] %(levelname)s [' + hostname + ' %(process)d] [%(filename)s:%(lineno)d] - %(message)s', 'format' : '[%(name)s][env:' + LOGGING_ENV + '] %(levelname)s [' + \
hostname + ' %(process)d] [%(filename)s:%(lineno)d] - %(message)s',
}, },
'raw' : { 'raw' : {
'format' : '%(message)s', 'format' : '%(message)s',
...@@ -189,7 +211,7 @@ LOGGING = { ...@@ -189,7 +211,7 @@ LOGGING = {
}, },
'handlers' : { 'handlers' : {
'console' : { 'console' : {
'level' : 'DEBUG', 'level' : 'DEBUG' if DEBUG else 'INFO',
'class' : 'logging.StreamHandler', 'class' : 'logging.StreamHandler',
'formatter' : 'standard', 'formatter' : 'standard',
'stream' : sys.stdout, 'stream' : sys.stdout,
...@@ -206,6 +228,12 @@ LOGGING = { ...@@ -206,6 +228,12 @@ LOGGING = {
'address' : SYSLOG_ADDRESS, 'address' : SYSLOG_ADDRESS,
'formatter' : 'syslog_format', 'formatter' : 'syslog_format',
}, },
'tracking' : {
'level' : 'DEBUG',
'class' : 'logging.handlers.WatchedFileHandler',
'filename' : TRACKING_LOG_FILE,
'formatter' : 'raw',
},
'mail_admins' : { 'mail_admins' : {
'level': 'ERROR', 'level': 'ERROR',
'class': 'django.utils.log.AdminEmailHandler', 'class': 'django.utils.log.AdminEmailHandler',
...@@ -218,7 +246,7 @@ LOGGING = { ...@@ -218,7 +246,7 @@ LOGGING = {
'level' : 'INFO' 'level' : 'INFO'
}, },
'tracking' : { 'tracking' : {
'handlers' : [] if DEBUG else ['syslogger'], # handlers, 'handlers' : ['tracking'],
'level' : 'DEBUG', 'level' : 'DEBUG',
'propagate' : False, 'propagate' : False,
}, },
...@@ -284,14 +312,16 @@ TEMPLATE_LOADERS = ( ...@@ -284,14 +312,16 @@ TEMPLATE_LOADERS = (
MIDDLEWARE_CLASSES = ( MIDDLEWARE_CLASSES = (
'util.middleware.ExceptionLoggingMiddleware', 'util.middleware.ExceptionLoggingMiddleware',
'django.middleware.cache.UpdateCacheMiddleware',
'django.middleware.common.CommonMiddleware', 'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware', 'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware', #'django.contrib.auth.middleware.AuthenticationMiddleware',
'cache_toolbox.middleware.CacheBackedAuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware', 'django.contrib.messages.middleware.MessageMiddleware',
'track.middleware.TrackMiddleware', 'track.middleware.TrackMiddleware',
'mitxmako.middleware.MakoMiddleware', 'mitxmako.middleware.MakoMiddleware',
# 'debug_toolbar.middleware.DebugToolbarMiddleware',
'askbot.middleware.anon_user.ConnectToSessionMessagesMiddleware', 'askbot.middleware.anon_user.ConnectToSessionMessagesMiddleware',
'askbot.middleware.forum_mode.ForumModeMiddleware', 'askbot.middleware.forum_mode.ForumModeMiddleware',
'askbot.middleware.cancel.CancelActionMiddleware', 'askbot.middleware.cancel.CancelActionMiddleware',
...@@ -299,10 +329,11 @@ MIDDLEWARE_CLASSES = ( ...@@ -299,10 +329,11 @@ MIDDLEWARE_CLASSES = (
'askbot.middleware.view_log.ViewLogMiddleware', 'askbot.middleware.view_log.ViewLogMiddleware',
'askbot.middleware.spaceless.SpacelessMiddleware', 'askbot.middleware.spaceless.SpacelessMiddleware',
# 'askbot.middleware.pagesize.QuestionsPageSizeMiddleware', # 'askbot.middleware.pagesize.QuestionsPageSizeMiddleware',
# 'debug_toolbar.middleware.DebugToolbarMiddleware',
) )
################################### APPS ####################################### ################################### APPS #######################################
def installed_apps(): def installed_apps(extras=()):
"""If you want to get a different set of INSTALLED_APPS out of this, you'll """If you want to get a different set of INSTALLED_APPS out of this, you'll
have to set ASKBOT_ENABLED and COURSEWARE_ENABLED to True/False and call have to set ASKBOT_ENABLED and COURSEWARE_ENABLED to True/False and call
this method. We can't just take these as params because other pieces of the this method. We can't just take these as params because other pieces of the
...@@ -339,6 +370,7 @@ def installed_apps(): ...@@ -339,6 +370,7 @@ def installed_apps():
return tuple(STANDARD_APPS + return tuple(STANDARD_APPS +
(COURSEWARE_APPS if COURSEWARE_ENABLED else []) + (COURSEWARE_APPS if COURSEWARE_ENABLED else []) +
(ASKBOT_APPS if ASKBOT_ENABLED else [])) (ASKBOT_APPS if ASKBOT_ENABLED else []) +
list(extras))
INSTALLED_APPS = installed_apps() INSTALLED_APPS = installed_apps()
...@@ -17,7 +17,7 @@ DATABASES = { ...@@ -17,7 +17,7 @@ DATABASES = {
SECRET_KEY = '85920908f28904ed733fe576320db18cabd7b6cd' SECRET_KEY = '85920908f28904ed733fe576320db18cabd7b6cd'
DEBUG = True DEBUG = True
TEMPLATE_DEBUG = False TEMPLATE_DEBUG = True
# This is disabling ASKBOT, but not properly overwriting INSTALLED_APPS. ??? # This is disabling ASKBOT, but not properly overwriting INSTALLED_APPS. ???
# It's because our ASKBOT_ENABLED here is actually shadowing the real one. # It's because our ASKBOT_ENABLED here is actually shadowing the real one.
...@@ -25,4 +25,18 @@ TEMPLATE_DEBUG = False ...@@ -25,4 +25,18 @@ TEMPLATE_DEBUG = False
# ASKBOT_ENABLED = True # ASKBOT_ENABLED = True
# MITX_FEATURES['SAMPLE'] = True # Switch to this system so we get around the shadowing # MITX_FEATURES['SAMPLE'] = True # Switch to this system so we get around the shadowing
# #
# INSTALLED_APPS = installed_apps() INSTALLED_APPS = installed_apps(extras=['debug_toolbar'])
MIDDLEWARE_CLASSES = ('debug_toolbar.middleware.DebugToolbarMiddleware',) + MIDDLEWARE_CLASSES
DEBUG_TOOLBAR_PANELS = (
'debug_toolbar.panels.version.VersionDebugPanel',
'debug_toolbar.panels.timer.TimerDebugPanel',
# 'debug_toolbar.panels.settings_vars.SettingsVarsDebugPanel',
'debug_toolbar.panels.headers.HeaderDebugPanel',
'debug_toolbar.panels.request_vars.RequestVarsDebugPanel',
'debug_toolbar.panels.sql.SQLDebugPanel',
'debug_toolbar.panels.signals.SignalDebugPanel',
'debug_toolbar.panels.logger.LoggingPanel',
# 'debug_toolbar.panels.profiling.ProfilingDebugPanel', # Lots of overhead
)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment