annotate gpp/settings/base.py @ 513:9e7ae8462f3f

Using celery to send mail out of the request/response cycle.
author Brian Neal <bgneal@gmail.com>
date Tue, 13 Dec 2011 02:07:55 +0000
parents 3fd369e1197f
children 6d816aa586c1
rev   line source
bgneal@499 1 # Base Django settings for the gpp project.
bgneal@499 2
bgneal@499 3 import os
bgneal@499 4 from decimal import Decimal
bgneal@499 5
bgneal@499 6 import django.utils.simplejson as json
bgneal@499 7 from django.contrib.messages import constants as message_constants
bgneal@512 8 import djcelery
bgneal@512 9
bgneal@499 10
bgneal@499 11 PROJECT_PATH = os.path.abspath(os.path.join(os.path.split(__file__)[0], '..'))
bgneal@499 12
bgneal@499 13 DEBUG = True
bgneal@499 14 TEMPLATE_DEBUG = DEBUG
bgneal@499 15
bgneal@499 16 ADMINS = (
bgneal@499 17 ('Brian Neal', 'admin@surfguitar101.com'),
bgneal@499 18 )
bgneal@499 19
bgneal@499 20 MANAGERS = ADMINS
bgneal@499 21
bgneal@499 22 AUTH_PROFILE_MODULE = 'bio.userprofile'
bgneal@499 23
bgneal@499 24 INTERNAL_IPS = ['127.0.0.1']
bgneal@499 25
bgneal@499 26 # Local time zone for this installation. Choices can be found here:
bgneal@499 27 # http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
bgneal@499 28 # although not all choices may be available on all operating systems.
bgneal@499 29 # If running in a Windows environment this must be set to the same as your
bgneal@499 30 # system time zone.
bgneal@499 31 TIME_ZONE = 'America/Chicago'
bgneal@499 32
bgneal@499 33 # Language code for this installation. All choices can be found here:
bgneal@499 34 # http://www.i18nguy.com/unicode/language-identifiers.html
bgneal@499 35 LANGUAGE_CODE = 'en-us'
bgneal@499 36
bgneal@499 37 SITE_ID = 1
bgneal@499 38
bgneal@499 39 # If you set this to False, Django will make some optimizations so as not
bgneal@499 40 # to load the internationalization machinery.
bgneal@499 41 USE_I18N = False
bgneal@499 42
bgneal@499 43 # Absolute path to the directory that holds media.
bgneal@499 44 # Example: "/home/media/media.lawrence.com/"
bgneal@499 45 MEDIA_ROOT = os.path.abspath(os.path.join(PROJECT_PATH, '..', 'media'))
bgneal@499 46
bgneal@499 47 # URL that handles the media served from MEDIA_ROOT. Make sure to use a
bgneal@499 48 # trailing slash if there is a path component (optional in other cases).
bgneal@499 49 # Examples: "http://media.lawrence.com", "http://example.com/media/"
bgneal@499 50 MEDIA_URL = '/media/'
bgneal@499 51
bgneal@499 52 # URL prefix for admin media -- CSS, JavaScript and images. Make sure to use a
bgneal@499 53 # trailing slash.
bgneal@499 54 # Examples: "http://foo.com/media/", "/media/".
bgneal@499 55 ADMIN_MEDIA_PREFIX = '/static/admin/'
bgneal@499 56
bgneal@499 57 # Staticfiles settings:
bgneal@499 58 STATICFILES_DIRS = [
bgneal@499 59 os.path.abspath(os.path.join(PROJECT_PATH, '..', 'static')),
bgneal@499 60 ]
bgneal@499 61 STATIC_ROOT = '/tmp/test_static_root'
bgneal@499 62 STATIC_URL = '/static/'
bgneal@499 63
bgneal@499 64 # Make this unique, and don't share it with anybody.
bgneal@499 65 SECRETS = json.load(open(os.path.join(PROJECT_PATH, 'settings', 'secrets.json')))
bgneal@499 66 SECRET_KEY = SECRETS['SECRET_KEY']
bgneal@499 67
bgneal@499 68 # List of Loader classes that know how to import templates from various sources.
bgneal@499 69
bgneal@499 70 TEMPLATE_LOADERS = (
bgneal@499 71 'django.template.loaders.filesystem.Loader',
bgneal@499 72 'django.template.loaders.app_directories.Loader',
bgneal@499 73 )
bgneal@499 74
bgneal@499 75 MIDDLEWARE_CLASSES = [
bgneal@499 76 'django.middleware.common.CommonMiddleware',
bgneal@499 77 'django.middleware.csrf.CsrfViewMiddleware',
bgneal@499 78 'django.contrib.sessions.middleware.SessionMiddleware',
bgneal@499 79 'django.contrib.messages.middleware.MessageMiddleware',
bgneal@499 80 'django.contrib.auth.middleware.AuthenticationMiddleware',
bgneal@499 81 'gpp.core.middleware.InactiveUserMiddleware',
bgneal@499 82 'gpp.core.middleware.WhosOnline',
bgneal@499 83 'django.contrib.flatpages.middleware.FlatpageFallbackMiddleware',
bgneal@499 84 ]
bgneal@499 85
bgneal@499 86 ROOT_URLCONF = 'gpp.urls'
bgneal@499 87
bgneal@499 88 TEMPLATE_DIRS = (
bgneal@499 89 # Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
bgneal@499 90 # Always use forward slashes, even on Windows.
bgneal@499 91 # Don't forget to use absolute paths, not relative paths.
bgneal@499 92 os.path.join(PROJECT_PATH, 'templates'),
bgneal@499 93 )
bgneal@499 94
bgneal@499 95 TEMPLATE_CONTEXT_PROCESSORS = (
bgneal@499 96 "django.contrib.auth.context_processors.auth",
bgneal@499 97 "django.core.context_processors.debug",
bgneal@499 98 "django.core.context_processors.request",
bgneal@499 99 "django.core.context_processors.media",
bgneal@499 100 "django.core.context_processors.static",
bgneal@499 101 "django.contrib.messages.context_processors.messages",
bgneal@499 102 )
bgneal@499 103
bgneal@499 104 INSTALLED_APPS = [
bgneal@499 105 'django.contrib.admin',
bgneal@499 106 'django.contrib.admindocs',
bgneal@499 107 'django.contrib.auth',
bgneal@499 108 'django.contrib.contenttypes',
bgneal@499 109 'django.contrib.flatpages',
bgneal@499 110 'django.contrib.humanize',
bgneal@499 111 'django.contrib.markup',
bgneal@499 112 'django.contrib.messages',
bgneal@499 113 'django.contrib.sessions',
bgneal@499 114 'django.contrib.sites',
bgneal@499 115 'django.contrib.staticfiles',
bgneal@512 116 'djcelery',
bgneal@499 117 'elsewhere',
bgneal@499 118 'haystack',
bgneal@499 119 'queued_search',
bgneal@512 120 'tagging',
bgneal@499 121 'accounts',
bgneal@499 122 'antispam',
bgneal@499 123 'bio',
bgneal@499 124 'bulletins',
bgneal@499 125 'comments',
bgneal@499 126 'contact',
bgneal@499 127 'core',
bgneal@499 128 'donations',
bgneal@499 129 'downloads',
bgneal@499 130 'forums',
bgneal@499 131 'gcalendar',
bgneal@499 132 'irc',
bgneal@499 133 'legacy',
bgneal@499 134 'mailer',
bgneal@499 135 'membermap',
bgneal@499 136 'messages',
bgneal@499 137 'news',
bgneal@499 138 'oembed',
bgneal@499 139 'podcast',
bgneal@499 140 'polls',
bgneal@499 141 'potd',
bgneal@499 142 'shoutbox',
bgneal@499 143 'smiley',
bgneal@499 144 'weblinks',
bgneal@499 145 'ygroup',
bgneal@499 146 ]
bgneal@499 147
bgneal@499 148 LOGIN_URL = '/accounts/login/'
bgneal@499 149 LOGIN_REDIRECT_URL = '/profile/me/'
bgneal@499 150 LOGOUT_URL = '/accounts/logout/'
bgneal@499 151
bgneal@499 152 FILE_UPLOAD_PERMISSIONS = 0644
bgneal@499 153 DEFAULT_FROM_EMAIL = ADMINS[0][1]
bgneal@499 154
bgneal@499 155 #######################################################################
bgneal@499 156 # Messages
bgneal@499 157 #######################################################################
bgneal@499 158 MESSAGE_STORAGE = 'django.contrib.messages.storage.session.SessionStorage'
bgneal@499 159 MESSAGE_TAGS = {
bgneal@499 160 message_constants.DEBUG: 'notice',
bgneal@499 161 message_constants.INFO: 'info',
bgneal@499 162 message_constants.SUCCESS: 'success',
bgneal@499 163 message_constants.WARNING: 'alert',
bgneal@499 164 message_constants.ERROR: 'error',
bgneal@499 165 }
bgneal@499 166
bgneal@499 167 #######################################################################
bgneal@499 168 # Email
bgneal@499 169 #######################################################################
bgneal@499 170 EMAIL_HOST = 'localhost'
bgneal@499 171 EMAIL_PORT = 1025
bgneal@512 172 EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
bgneal@499 173
bgneal@499 174 #######################################################################
bgneal@499 175 # Sessions
bgneal@499 176 #######################################################################
bgneal@499 177 SESSION_ENGINE = "django.contrib.sessions.backends.cached_db"
bgneal@499 178 SESSION_COOKIE_AGE = 2 * 7 * 24 * 60 * 60 # 2 weeks in seconds
bgneal@499 179 SESSION_COOKIE_DOMAIN = None
bgneal@499 180 SESSION_COOKIE_NAME = 'sg101_sessionid'
bgneal@499 181 SESSION_COOKIE_PATH = '/'
bgneal@499 182 SESSION_COOKIE_SECURE = False
bgneal@499 183 SESSION_EXPIRE_AT_BROWSER_CLOSE = False
bgneal@499 184 SESSION_SAVE_EVERY_REQUEST = False
bgneal@499 185
bgneal@499 186 #######################################################################
bgneal@499 187 # Tagging Specific Settings
bgneal@499 188 #######################################################################
bgneal@499 189 FORCE_LOWERCASE_TAGS = True
bgneal@499 190 MAX_TAG_LENGTH = 50
bgneal@499 191
bgneal@499 192 #######################################################################
bgneal@499 193 # Haystack Search Settings
bgneal@499 194 #######################################################################
bgneal@499 195 HAYSTACK_SITECONF = 'gpp.search_sites'
bgneal@499 196 HAYSTACK_SEARCH_ENGINE = 'xapian'
bgneal@499 197 HAYSTACK_XAPIAN_PATH = os.path.join(PROJECT_PATH, 'xapian_index')
bgneal@499 198
bgneal@499 199
bgneal@499 200 #######################################################################
bgneal@512 201 # Celery integration & settings
bgneal@512 202 #######################################################################
bgneal@512 203 BROKER_URL = 'redis://localhost:6379/1'
bgneal@512 204 BROKER_POOL_LIMIT = 10
bgneal@512 205
bgneal@512 206 CELERY_IGNORE_RESULT = False
bgneal@512 207 CELERY_RESULT_BACKEND = 'redis'
bgneal@512 208 CELERY_REDIS_HOST = 'localhost'
bgneal@512 209 CELERY_REDIS_PORT = 6379
bgneal@512 210 CELERY_REDIS_DB = 1
bgneal@512 211
bgneal@512 212 CELERY_DISABLE_RATE_LIMITS = True
bgneal@512 213 CELERY_SEND_TASK_ERROR_EMAILS = True
bgneal@512 214
bgneal@512 215 djcelery.setup_loader()
bgneal@512 216
bgneal@512 217 #######################################################################
bgneal@499 218 # GPP Specific Settings
bgneal@499 219 #######################################################################
bgneal@499 220 GPP_LOG_LEVEL = 0
bgneal@512 221 GPP_SEND_EMAIL = True
bgneal@499 222 GPP_NO_REPLY_EMAIL = 'no_reply'
bgneal@499 223 AVATAR_DIR = 'avatars'
bgneal@499 224 MAX_AVATAR_SIZE_BYTES = 2 * 1024 * 1024
bgneal@499 225 MAX_AVATAR_SIZE_PIXELS = 100
bgneal@499 226 AVATAR_DEFAULT_URL = MEDIA_URL + AVATAR_DIR + '/default.png'
bgneal@499 227
bgneal@499 228 # Donations application settings:
bgneal@499 229 DONATIONS_DEBUG = False
bgneal@499 230 DONATIONS_ITEM_NAME = 'Donation for SurfGuitar101.com'
bgneal@499 231 DONATIONS_BUSINESS = 'brian@surfguitar101.com'
bgneal@499 232 DONATIONS_BUSINESS_DEBUG = 'bgneal_1246137628_biz@gmail.com'
bgneal@499 233 DONATIONS_GOAL = Decimal('100.00') # monthly goal
bgneal@499 234 DONATIONS_ANON_NAME = u'Anonymous'
bgneal@499 235 DONATIONS_ITEM_NUM = '500' # donation w/name listed
bgneal@499 236 DONATIONS_ITEM_ANON_NUM = '501' # donation listed as anonymous
bgneal@499 237
bgneal@499 238 # Oembed settings
bgneal@499 239 OEMBED_MAXWIDTH = 480
bgneal@499 240 OEMBED_MAXHEIGHT = 295
bgneal@499 241
bgneal@499 242 # GCalendar settings
bgneal@499 243 GCAL_CALENDAR_ID = 'i81lu3fkh57sgqqenogefd9v78@group.calendar.google.com'
bgneal@499 244
bgneal@499 245 # Google OAuth settings
bgneal@499 246 GOOGLE_OAUTH_CONSUMER_KEY = 'surfguitar101.com'
bgneal@499 247 GOOGLE_OAUTH_PRIVATE_KEY_PATH = '/home/brian/google/myrsakey.pem'
bgneal@499 248
bgneal@499 249 #######################################################################
bgneal@499 250 # Asynchronous settings (queues, queued_search, redis, celery, etc)
bgneal@499 251 #######################################################################
bgneal@499 252 QUEUE_BACKEND = 'redisd'
bgneal@499 253 QUEUE_REDIS_CONNECTION = 'localhost:6379'
bgneal@499 254 QUEUE_REDIS_DB = 0
bgneal@499 255
bgneal@499 256 #######################################################################
bgneal@499 257 # Open Graph Protocol related settings
bgneal@499 258 #######################################################################
bgneal@499 259 OGP_DEFAULT_IMAGE = 'http://surfguitar101.com/media/podcast/podcast_logo.jpg'
bgneal@499 260 OGP_FB_ID = '100001558124013'
bgneal@499 261
bgneal@499 262 #######################################################################
bgneal@499 263 # URL's of 3rd party Javascript and CSS files.
bgneal@499 264 # These dictionaries are used by core/templatetags/script_tags, and
bgneal@499 265 # should also be used by developers when creating form media classes.
bgneal@499 266 GPP_THIRD_PARTY_JS = {
bgneal@499 267 'jquery': [
bgneal@499 268 'http://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js',
bgneal@499 269 ],
bgneal@499 270 'jquery-jeditable': [
bgneal@499 271 'js/jquery.jeditable.mini.js',
bgneal@499 272 ],
bgneal@499 273 'jquery-ui': [
bgneal@499 274 'http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.12/jquery-ui.min.js',
bgneal@499 275 ],
bgneal@499 276 'markitup': [
bgneal@499 277 'js/markitup/jquery.markitup.pack.js',
bgneal@499 278 'js/markitup/sets/markdown/set.js',
bgneal@499 279 ],
bgneal@499 280 'tiny_mce': [
bgneal@499 281 'js/tiny_mce/tiny_mce.js',
bgneal@499 282 'js/tiny_mce_init_std.js',
bgneal@499 283 ],
bgneal@499 284 }
bgneal@499 285
bgneal@499 286 GPP_THIRD_PARTY_CSS = {
bgneal@499 287 'jquery-ui': [
bgneal@499 288 'http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.12/themes/redmond/jquery-ui.css',
bgneal@499 289 ],
bgneal@499 290 'markitup': [
bgneal@499 291 'js/markitup/skins/markitup/style.css',
bgneal@499 292 'js/markitup/sets/markdown/style.css',
bgneal@499 293 ],
bgneal@499 294 }
bgneal@499 295