2009-07-05 18:15:58 +00:00
|
|
|
import sys
|
2009-08-09 21:03:10 +00:00
|
|
|
import os
|
2011-11-27 02:41:12 -05:00
|
|
|
|
2009-08-09 21:03:10 +00:00
|
|
|
# ===========================
|
|
|
|
# = Directory Declaractions =
|
|
|
|
# ===========================
|
2009-07-19 16:55:08 +00:00
|
|
|
|
2012-07-26 22:12:48 -07:00
|
|
|
CURRENT_DIR = os.path.dirname(__file__)
|
2011-04-11 09:30:39 -04:00
|
|
|
NEWSBLUR_DIR = CURRENT_DIR
|
2013-03-29 10:58:20 -07:00
|
|
|
TEMPLATE_DIRS = (os.path.join(CURRENT_DIR, 'templates'),
|
|
|
|
os.path.join(CURRENT_DIR, 'vendor/zebra/templates'),)
|
2011-07-17 20:53:30 -07:00
|
|
|
MEDIA_ROOT = os.path.join(CURRENT_DIR, 'media')
|
2011-11-07 09:35:51 -08:00
|
|
|
STATIC_ROOT = os.path.join(CURRENT_DIR, 'static')
|
2011-07-17 20:53:30 -07:00
|
|
|
UTILS_ROOT = os.path.join(CURRENT_DIR, 'utils')
|
|
|
|
VENDOR_ROOT = os.path.join(CURRENT_DIR, 'vendor')
|
|
|
|
LOG_FILE = os.path.join(CURRENT_DIR, 'logs/newsblur.log')
|
|
|
|
IMAGE_MASK = os.path.join(CURRENT_DIR, 'media/img/mask.png')
|
2009-07-19 16:55:08 +00:00
|
|
|
|
2009-09-08 03:15:49 +00:00
|
|
|
# ==============
|
|
|
|
# = PYTHONPATH =
|
|
|
|
# ==============
|
|
|
|
|
2010-02-02 18:01:02 -05:00
|
|
|
if '/utils' not in ' '.join(sys.path):
|
2011-04-11 21:57:45 -04:00
|
|
|
sys.path.append(UTILS_ROOT)
|
2012-07-16 23:40:17 -07:00
|
|
|
|
2011-04-11 21:57:45 -04:00
|
|
|
if '/vendor' not in ' '.join(sys.path):
|
|
|
|
sys.path.append(VENDOR_ROOT)
|
2012-07-16 23:40:17 -07:00
|
|
|
|
2013-05-15 17:52:35 -07:00
|
|
|
import logging
|
|
|
|
import datetime
|
|
|
|
import redis
|
|
|
|
import raven
|
|
|
|
import django.http
|
|
|
|
import re
|
|
|
|
from mongoengine import connect
|
|
|
|
from boto.s3.connection import S3Connection
|
|
|
|
from utils import jammit
|
|
|
|
|
|
|
|
# ===================
|
|
|
|
# = Server Settings =
|
|
|
|
# ===================
|
|
|
|
|
|
|
|
ADMINS = (
|
|
|
|
('Samuel Clay', 'samuel@newsblur.com'),
|
|
|
|
)
|
|
|
|
|
|
|
|
SERVER_NAME = 'newsblur'
|
|
|
|
SERVER_EMAIL = 'server@newsblur.com'
|
|
|
|
HELLO_EMAIL = 'hello@newsblur.com'
|
|
|
|
NEWSBLUR_URL = 'http://www.newsblur.com'
|
|
|
|
SECRET_KEY = 'YOUR_SECRET_KEY'
|
|
|
|
|
|
|
|
|
2009-08-09 21:03:10 +00:00
|
|
|
# ===================
|
|
|
|
# = Global Settings =
|
|
|
|
# ===================
|
2009-06-16 03:08:55 +00:00
|
|
|
|
2012-02-28 12:17:38 -08:00
|
|
|
DEBUG = False
|
2011-09-01 09:11:29 -07:00
|
|
|
TEST_DEBUG = False
|
2011-05-08 19:25:58 -04:00
|
|
|
SEND_BROKEN_LINK_EMAILS = False
|
2011-04-11 09:30:39 -04:00
|
|
|
MANAGERS = ADMINS
|
2010-10-16 18:52:52 -04:00
|
|
|
PAYPAL_RECEIVER_EMAIL = 'samuel@ofbrooklyn.com'
|
2011-04-11 09:30:39 -04:00
|
|
|
TIME_ZONE = 'GMT'
|
|
|
|
LANGUAGE_CODE = 'en-us'
|
|
|
|
SITE_ID = 1
|
|
|
|
USE_I18N = False
|
|
|
|
LOGIN_REDIRECT_URL = '/'
|
|
|
|
LOGIN_URL = '/reader/login'
|
2009-08-09 21:03:10 +00:00
|
|
|
# URL prefix for admin media -- CSS, JavaScript and images. Make sure to use a
|
|
|
|
# trailing slash.
|
|
|
|
# Examples: "http://foo.com/media/", "/media/".
|
2011-04-11 09:30:39 -04:00
|
|
|
ADMIN_MEDIA_PREFIX = '/media/admin/'
|
2013-04-27 14:26:53 -04:00
|
|
|
EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
|
2011-12-18 23:48:44 -08:00
|
|
|
CIPHER_USERNAMES = False
|
2012-02-28 12:17:38 -08:00
|
|
|
DEBUG_ASSETS = DEBUG
|
2012-08-09 20:42:04 -07:00
|
|
|
HOMEPAGE_USERNAME = 'popular'
|
2013-03-20 16:43:20 -07:00
|
|
|
ALLOWED_HOSTS = ['*']
|
2009-08-09 21:03:10 +00:00
|
|
|
|
|
|
|
# ===============
|
|
|
|
# = Enviornment =
|
|
|
|
# ===============
|
|
|
|
|
2011-07-17 20:53:30 -07:00
|
|
|
PRODUCTION = NEWSBLUR_DIR.find('/home/conesus/newsblur') == 0
|
|
|
|
STAGING = NEWSBLUR_DIR.find('/home/conesus/staging') == 0
|
2013-05-09 01:27:53 -07:00
|
|
|
DEVELOPMENT = (NEWSBLUR_DIR.find('/Users/') == 0)
|
2011-04-11 09:30:39 -04:00
|
|
|
|
2009-08-09 21:03:10 +00:00
|
|
|
# ===========================
|
|
|
|
# = Django-specific Modules =
|
|
|
|
# ===========================
|
|
|
|
|
2009-06-16 03:08:55 +00:00
|
|
|
TEMPLATE_CONTEXT_PROCESSORS = (
|
2010-10-30 00:27:52 -04:00
|
|
|
"django.contrib.auth.context_processors.auth",
|
2009-06-16 03:08:55 +00:00
|
|
|
"django.core.context_processors.debug",
|
2010-06-11 20:55:38 -04:00
|
|
|
"django.core.context_processors.media",
|
|
|
|
'django.core.context_processors.request',
|
2009-06-16 03:08:55 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
MIDDLEWARE_CLASSES = (
|
|
|
|
'django.middleware.gzip.GZipMiddleware',
|
|
|
|
'django.middleware.common.CommonMiddleware',
|
2010-06-11 20:55:38 -04:00
|
|
|
'django.contrib.sessions.middleware.SessionMiddleware',
|
2009-07-19 16:55:08 +00:00
|
|
|
'django.contrib.auth.middleware.AuthenticationMiddleware',
|
2012-07-13 14:56:12 -07:00
|
|
|
'apps.profile.middleware.TimingMiddleware',
|
2010-06-30 13:36:51 -04:00
|
|
|
'apps.profile.middleware.LastSeenMiddleware',
|
2011-05-08 19:25:58 -04:00
|
|
|
'apps.profile.middleware.SQLLogToConsoleMiddleware',
|
2012-06-28 19:47:30 -07:00
|
|
|
'subdomains.middleware.SubdomainMiddleware',
|
2012-07-05 18:30:16 -07:00
|
|
|
'apps.profile.middleware.SimpsonsMiddleware',
|
2013-03-18 11:32:24 -07:00
|
|
|
'apps.profile.middleware.ServerHostnameMiddleware',
|
2009-12-18 20:54:14 +00:00
|
|
|
# 'debug_toolbar.middleware.DebugToolbarMiddleware',
|
2009-06-16 03:08:55 +00:00
|
|
|
)
|
|
|
|
|
2013-03-20 16:39:27 -07:00
|
|
|
AUTHENTICATION_BACKENDS = ('django.contrib.auth.backends.ModelBackend',)
|
|
|
|
|
2011-05-08 19:25:58 -04:00
|
|
|
# ===========
|
|
|
|
# = Logging =
|
|
|
|
# ===========
|
|
|
|
|
|
|
|
LOGGING = {
|
|
|
|
'version': 1,
|
|
|
|
'disable_existing_loggers': False,
|
|
|
|
'formatters': {
|
|
|
|
'verbose': {
|
2013-05-08 02:15:55 -07:00
|
|
|
'format': '[%(asctime)-12s] %(message)s',
|
2011-05-08 19:25:58 -04:00
|
|
|
'datefmt': '%b %d %H:%M:%S'
|
|
|
|
},
|
|
|
|
'simple': {
|
|
|
|
'format': '%(message)s'
|
|
|
|
},
|
|
|
|
},
|
|
|
|
'handlers': {
|
|
|
|
'null': {
|
|
|
|
'level':'DEBUG',
|
|
|
|
'class':'django.utils.log.NullHandler',
|
|
|
|
},
|
|
|
|
'console':{
|
|
|
|
'level': 'DEBUG',
|
|
|
|
'class': 'logging.StreamHandler',
|
|
|
|
'formatter': 'verbose'
|
|
|
|
},
|
|
|
|
'log_file':{
|
|
|
|
'level': 'DEBUG',
|
|
|
|
'class': 'logging.handlers.RotatingFileHandler',
|
|
|
|
'filename': LOG_FILE,
|
|
|
|
'maxBytes': '16777216', # 16megabytes
|
|
|
|
'formatter': 'verbose'
|
|
|
|
},
|
|
|
|
'mail_admins': {
|
|
|
|
'level': 'ERROR',
|
|
|
|
'class': 'django.utils.log.AdminEmailHandler',
|
2013-03-20 15:05:52 -07:00
|
|
|
'filters': ['require_debug_false'],
|
2011-05-08 19:25:58 -04:00
|
|
|
'include_html': True,
|
|
|
|
}
|
|
|
|
},
|
|
|
|
'loggers': {
|
|
|
|
'django.request': {
|
2013-03-20 08:24:11 -07:00
|
|
|
'handlers': ['console', 'log_file'],
|
2011-05-08 19:25:58 -04:00
|
|
|
'level': 'ERROR',
|
|
|
|
'propagate': True,
|
|
|
|
},
|
|
|
|
'django.db.backends': {
|
|
|
|
'handlers': ['null'],
|
|
|
|
'level': 'DEBUG',
|
|
|
|
'propagate': False,
|
|
|
|
},
|
|
|
|
'newsblur': {
|
|
|
|
'handlers': ['console', 'log_file'],
|
|
|
|
'level': 'DEBUG',
|
|
|
|
'propagate': False,
|
|
|
|
},
|
2011-07-17 20:53:30 -07:00
|
|
|
'apps': {
|
2011-05-08 19:25:58 -04:00
|
|
|
'handlers': ['log_file'],
|
|
|
|
'level': 'INFO',
|
|
|
|
'propagate': True,
|
|
|
|
},
|
2013-03-20 15:05:52 -07:00
|
|
|
},
|
|
|
|
'filters': {
|
|
|
|
'require_debug_false': {
|
|
|
|
'()': 'django.utils.log.RequireDebugFalse'
|
|
|
|
}
|
|
|
|
},
|
2011-05-08 19:25:58 -04:00
|
|
|
}
|
|
|
|
|
2009-08-09 21:03:10 +00:00
|
|
|
# ==========================
|
|
|
|
# = Miscellaneous Settings =
|
|
|
|
# ==========================
|
|
|
|
|
2011-01-15 18:41:41 -05:00
|
|
|
DAYS_OF_UNREAD = 14
|
2011-11-14 09:18:15 -08:00
|
|
|
SUBSCRIBER_EXPIRE = 2
|
2011-01-15 18:41:41 -05:00
|
|
|
|
|
|
|
AUTH_PROFILE_MODULE = 'newsblur.UserProfile'
|
2009-07-18 23:41:57 +00:00
|
|
|
TEST_DATABASE_COLLATION = 'utf8_general_ci'
|
2011-01-15 18:41:41 -05:00
|
|
|
TEST_DATABASE_NAME = 'newsblur_test'
|
|
|
|
ROOT_URLCONF = 'urls'
|
|
|
|
INTERNAL_IPS = ('127.0.0.1',)
|
|
|
|
LOGGING_LOG_SQL = True
|
2012-08-11 13:56:30 -07:00
|
|
|
APPEND_SLASH = False
|
2013-05-08 02:15:55 -07:00
|
|
|
SOUTH_TESTS_MIGRATE = False
|
2011-08-29 18:43:17 -07:00
|
|
|
SESSION_ENGINE = "django.contrib.sessions.backends.db"
|
2011-01-15 18:41:41 -05:00
|
|
|
TEST_RUNNER = "utils.testrunner.TestRunner"
|
|
|
|
SESSION_COOKIE_NAME = 'newsblur_sessionid'
|
|
|
|
SESSION_COOKIE_AGE = 60*60*24*365*2 # 2 years
|
2012-07-01 18:34:34 -07:00
|
|
|
SESSION_COOKIE_DOMAIN = '.newsblur.com'
|
2012-10-25 14:18:25 -07:00
|
|
|
SENTRY_DSN = 'https://XXXNEWSBLURXXX@app.getsentry.com/99999999'
|
2009-06-16 03:08:55 +00:00
|
|
|
|
2012-06-27 01:02:09 -07:00
|
|
|
# ==============
|
|
|
|
# = Subdomains =
|
|
|
|
# ==============
|
|
|
|
|
|
|
|
SUBDOMAIN_URLCONFS = {
|
|
|
|
None: 'urls',
|
|
|
|
'www': 'urls',
|
|
|
|
}
|
2012-06-28 10:14:42 -07:00
|
|
|
REMOVE_WWW_FROM_DOMAIN = True
|
2012-06-27 01:02:09 -07:00
|
|
|
|
2010-08-16 12:52:39 -04:00
|
|
|
# ===========
|
|
|
|
# = Logging =
|
|
|
|
# ===========
|
|
|
|
|
|
|
|
LOG_LEVEL = logging.DEBUG
|
|
|
|
LOG_TO_STREAM = False
|
|
|
|
|
2009-08-09 21:03:10 +00:00
|
|
|
# ===============
|
|
|
|
# = Django Apps =
|
|
|
|
# ===============
|
|
|
|
|
2009-06-16 03:08:55 +00:00
|
|
|
INSTALLED_APPS = (
|
|
|
|
'django.contrib.auth',
|
|
|
|
'django.contrib.contenttypes',
|
|
|
|
'django.contrib.sessions',
|
|
|
|
'django.contrib.sites',
|
|
|
|
'django.contrib.admin',
|
2010-03-02 10:56:25 -05:00
|
|
|
'django_extensions',
|
2010-08-31 18:07:47 -04:00
|
|
|
'djcelery',
|
2009-06-16 03:08:55 +00:00
|
|
|
'apps.rss_feeds',
|
|
|
|
'apps.reader',
|
|
|
|
'apps.analyzer',
|
2010-06-29 20:16:09 -04:00
|
|
|
'apps.feed_import',
|
2009-06-16 03:08:55 +00:00
|
|
|
'apps.profile',
|
2011-02-28 23:27:58 -05:00
|
|
|
'apps.recommendations',
|
2011-04-15 11:34:41 -04:00
|
|
|
'apps.statistics',
|
2011-06-05 17:51:57 -04:00
|
|
|
'apps.static',
|
|
|
|
'apps.mobile',
|
2012-03-27 16:26:07 -07:00
|
|
|
'apps.push',
|
2011-12-15 09:10:37 -08:00
|
|
|
'apps.social',
|
2012-03-19 11:15:26 -07:00
|
|
|
'apps.oauth',
|
2012-07-13 14:33:16 -07:00
|
|
|
'apps.search',
|
2012-08-12 16:49:14 -07:00
|
|
|
'apps.categories',
|
2010-06-11 16:55:07 -04:00
|
|
|
'south',
|
2010-07-06 13:56:32 -04:00
|
|
|
'utils',
|
2011-04-11 21:57:45 -04:00
|
|
|
'vendor',
|
|
|
|
'vendor.typogrify',
|
|
|
|
'vendor.paypal.standard.ipn',
|
2012-02-27 21:46:34 -08:00
|
|
|
'vendor.zebra',
|
2013-05-07 18:43:47 -07:00
|
|
|
'vendor.haystack',
|
2009-07-25 02:21:12 +00:00
|
|
|
)
|
2010-02-11 01:28:47 -05:00
|
|
|
|
2012-02-27 21:46:34 -08:00
|
|
|
# ==========
|
|
|
|
# = Stripe =
|
|
|
|
# ==========
|
|
|
|
|
|
|
|
STRIPE_SECRET = "YOUR-SECRET-API-KEY"
|
|
|
|
STRIPE_PUBLISHABLE = "YOUR-PUBLISHABLE-API-KEY"
|
|
|
|
ZEBRA_ENABLE_APP = True
|
2010-04-05 00:47:21 -04:00
|
|
|
|
2010-08-31 18:15:00 -04:00
|
|
|
# ==========
|
|
|
|
# = Celery =
|
|
|
|
# ==========
|
|
|
|
|
|
|
|
import djcelery
|
|
|
|
djcelery.setup_loader()
|
2010-09-20 19:22:19 -04:00
|
|
|
CELERY_ROUTES = {
|
2012-06-28 12:42:49 -07:00
|
|
|
"work-queue": {
|
|
|
|
"queue": "work_queue",
|
|
|
|
"binding_key": "work_queue"
|
|
|
|
},
|
2010-09-28 19:22:52 -04:00
|
|
|
"new-feeds": {
|
2010-09-20 19:31:17 -04:00
|
|
|
"queue": "new_feeds",
|
2010-09-28 19:22:52 -04:00
|
|
|
"binding_key": "new_feeds"
|
2010-09-20 19:22:19 -04:00
|
|
|
},
|
2012-03-28 15:49:21 -07:00
|
|
|
"push-feeds": {
|
|
|
|
"queue": "push_feeds",
|
|
|
|
"binding_key": "push_feeds"
|
|
|
|
},
|
2010-09-28 19:22:52 -04:00
|
|
|
"update-feeds": {
|
2010-09-20 19:31:17 -04:00
|
|
|
"queue": "update_feeds",
|
2010-09-28 19:22:52 -04:00
|
|
|
"binding_key": "update_feeds"
|
2010-09-20 19:22:19 -04:00
|
|
|
},
|
2012-07-16 23:40:17 -07:00
|
|
|
"beat-tasks": {
|
|
|
|
"queue": "beat_tasks",
|
|
|
|
"binding_key": "beat_tasks"
|
|
|
|
},
|
2010-09-20 19:22:19 -04:00
|
|
|
}
|
|
|
|
CELERY_QUEUES = {
|
2012-06-28 12:42:49 -07:00
|
|
|
"work_queue": {
|
|
|
|
"exchange": "work_queue",
|
|
|
|
"exchange_type": "direct",
|
|
|
|
"binding_key": "work_queue",
|
|
|
|
},
|
2010-09-20 19:22:19 -04:00
|
|
|
"new_feeds": {
|
2010-09-28 19:22:52 -04:00
|
|
|
"exchange": "new_feeds",
|
|
|
|
"exchange_type": "direct",
|
|
|
|
"binding_key": "new_feeds"
|
2010-09-20 19:22:19 -04:00
|
|
|
},
|
2012-03-28 15:49:21 -07:00
|
|
|
"push_feeds": {
|
|
|
|
"exchange": "push_feeds",
|
|
|
|
"exchange_type": "direct",
|
|
|
|
"binding_key": "push_feeds"
|
|
|
|
},
|
2010-09-20 19:22:19 -04:00
|
|
|
"update_feeds": {
|
2010-09-28 19:22:52 -04:00
|
|
|
"exchange": "update_feeds",
|
|
|
|
"exchange_type": "direct",
|
|
|
|
"binding_key": "update_feeds"
|
2010-09-20 19:22:19 -04:00
|
|
|
},
|
2012-07-16 23:40:17 -07:00
|
|
|
"beat_tasks": {
|
|
|
|
"exchange": "beat_tasks",
|
|
|
|
"exchange_type": "direct",
|
|
|
|
"binding_key": "beat_tasks"
|
|
|
|
},
|
2013-03-14 12:55:10 -07:00
|
|
|
"beat_feeds_task": {
|
|
|
|
"exchange": "beat_feeds_task",
|
|
|
|
"exchange_type": "direct",
|
|
|
|
"binding_key": "beat_feeds_task"
|
|
|
|
},
|
2010-09-20 19:22:19 -04:00
|
|
|
}
|
2012-06-28 12:42:49 -07:00
|
|
|
CELERY_DEFAULT_QUEUE = "work_queue"
|
2012-02-26 22:33:06 -08:00
|
|
|
|
2012-02-27 12:35:07 -08:00
|
|
|
CELERYD_PREFETCH_MULTIPLIER = 1
|
2013-05-08 02:15:55 -07:00
|
|
|
CELERY_IMPORTS = ("apps.rss_feeds.tasks",
|
|
|
|
"apps.social.tasks",
|
2012-07-20 19:43:28 -07:00
|
|
|
"apps.reader.tasks",
|
2012-12-10 13:33:37 -08:00
|
|
|
"apps.feed_import.tasks",
|
|
|
|
"apps.statistics.tasks",)
|
2011-04-11 09:30:39 -04:00
|
|
|
CELERYD_CONCURRENCY = 4
|
|
|
|
CELERY_IGNORE_RESULT = True
|
|
|
|
CELERY_ACKS_LATE = True # Retry if task fails
|
2010-11-08 12:10:44 -05:00
|
|
|
CELERYD_MAX_TASKS_PER_CHILD = 10
|
2012-02-27 12:35:07 -08:00
|
|
|
CELERYD_TASK_TIME_LIMIT = 12 * 30
|
2011-04-11 09:30:39 -04:00
|
|
|
CELERY_DISABLE_RATE_LIMITS = True
|
2012-08-06 17:52:33 -07:00
|
|
|
SECONDS_TO_DELAY_CELERY_EMAILS = 60
|
2010-08-31 18:15:00 -04:00
|
|
|
|
2012-07-16 23:40:17 -07:00
|
|
|
CELERYBEAT_SCHEDULE = {
|
|
|
|
'task-feeds': {
|
|
|
|
'task': 'task-feeds',
|
|
|
|
'schedule': datetime.timedelta(minutes=1),
|
2013-03-14 12:55:10 -07:00
|
|
|
'options': {'queue': 'beat_feeds_task'},
|
|
|
|
},
|
|
|
|
'freshen-homepage': {
|
|
|
|
'task': 'freshen-homepage',
|
|
|
|
'schedule': datetime.timedelta(hours=1),
|
2012-07-16 23:40:17 -07:00
|
|
|
'options': {'queue': 'beat_tasks'},
|
|
|
|
},
|
|
|
|
'collect-stats': {
|
|
|
|
'task': 'collect-stats',
|
|
|
|
'schedule': datetime.timedelta(minutes=1),
|
|
|
|
'options': {'queue': 'beat_tasks'},
|
|
|
|
},
|
|
|
|
'collect-feedback': {
|
|
|
|
'task': 'collect-feedback',
|
|
|
|
'schedule': datetime.timedelta(minutes=1),
|
|
|
|
'options': {'queue': 'beat_tasks'},
|
|
|
|
},
|
2012-07-31 11:41:30 -07:00
|
|
|
'share-popular-stories': {
|
|
|
|
'task': 'share-popular-stories',
|
|
|
|
'schedule': datetime.timedelta(hours=1),
|
|
|
|
'options': {'queue': 'beat_tasks'},
|
|
|
|
},
|
2012-09-27 13:18:51 -07:00
|
|
|
'clean-analytics': {
|
|
|
|
'task': 'clean-analytics',
|
|
|
|
'schedule': datetime.timedelta(hours=12),
|
|
|
|
'options': {'queue': 'beat_tasks'},
|
|
|
|
},
|
2012-12-05 14:25:23 -08:00
|
|
|
'premium-expire': {
|
|
|
|
'task': 'premium-expire',
|
|
|
|
'schedule': datetime.timedelta(hours=24),
|
|
|
|
'options': {'queue': 'beat_tasks'},
|
|
|
|
},
|
2013-05-13 18:03:17 -07:00
|
|
|
'activate-next-new-user': {
|
|
|
|
'task': 'activate-next-new-user',
|
2013-06-18 11:16:16 -07:00
|
|
|
'schedule': datetime.timedelta(minutes=2),
|
2013-05-13 18:03:17 -07:00
|
|
|
'options': {'queue': 'beat_tasks'},
|
|
|
|
},
|
2012-07-16 23:40:17 -07:00
|
|
|
}
|
|
|
|
|
2012-09-06 17:16:01 -07:00
|
|
|
# =========
|
|
|
|
# = Mongo =
|
|
|
|
# =========
|
|
|
|
|
|
|
|
MONGO_DB = {
|
|
|
|
'host': '127.0.0.1:27017',
|
|
|
|
'name': 'newsblur',
|
|
|
|
}
|
|
|
|
MONGO_ANALYTICS_DB = {
|
|
|
|
'host': '127.0.0.1:27017',
|
|
|
|
'name': 'nbanalytics',
|
|
|
|
}
|
|
|
|
|
2011-02-09 16:28:10 -05:00
|
|
|
# ====================
|
|
|
|
# = Database Routers =
|
|
|
|
# ====================
|
|
|
|
|
|
|
|
class MasterSlaveRouter(object):
|
|
|
|
"""A router that sets up a simple master/slave configuration"""
|
2013-05-08 02:15:55 -07:00
|
|
|
|
2011-02-09 16:28:10 -05:00
|
|
|
def db_for_read(self, model, **hints):
|
|
|
|
"Point all read operations to a random slave"
|
2011-02-09 16:34:05 -05:00
|
|
|
return 'slave'
|
2013-05-08 02:15:55 -07:00
|
|
|
|
2011-02-09 16:28:10 -05:00
|
|
|
def db_for_write(self, model, **hints):
|
|
|
|
"Point all write operations to the master"
|
2011-02-09 16:34:05 -05:00
|
|
|
return 'default'
|
2013-05-08 02:15:55 -07:00
|
|
|
|
2011-02-09 16:28:10 -05:00
|
|
|
def allow_relation(self, obj1, obj2, **hints):
|
|
|
|
"Allow any relation between two objects in the db pool"
|
2011-02-09 16:34:05 -05:00
|
|
|
db_list = ('slave','default')
|
2011-02-09 16:28:10 -05:00
|
|
|
if obj1._state.db in db_list and obj2._state.db in db_list:
|
|
|
|
return True
|
|
|
|
return None
|
2013-05-08 02:15:55 -07:00
|
|
|
|
2011-02-09 16:28:10 -05:00
|
|
|
def allow_syncdb(self, db, model):
|
|
|
|
"Explicitly put all models on all databases."
|
|
|
|
return True
|
2011-11-04 09:45:10 -07:00
|
|
|
|
2011-11-05 17:08:31 -07:00
|
|
|
# =========
|
|
|
|
# = Redis =
|
|
|
|
# =========
|
|
|
|
|
|
|
|
REDIS = {
|
2013-04-21 06:07:01 -07:00
|
|
|
'host': 'db12',
|
2011-11-05 17:08:31 -07:00
|
|
|
}
|
2013-06-18 12:21:27 -07:00
|
|
|
REDIS2 = {
|
|
|
|
'host': 'db13',
|
|
|
|
}
|
|
|
|
CELERY_REDIS_DB = 4
|
2013-03-20 19:26:10 -07:00
|
|
|
SESSION_REDIS_DB = 5
|
2011-11-05 17:08:31 -07:00
|
|
|
|
2012-03-11 16:13:05 -07:00
|
|
|
# =================
|
|
|
|
# = Elasticsearch =
|
|
|
|
# =================
|
|
|
|
|
2013-04-28 21:39:40 -07:00
|
|
|
ELASTICSEARCH_HOSTS = ['db01:9200']
|
2012-03-11 16:13:05 -07:00
|
|
|
|
2011-12-20 11:49:49 -08:00
|
|
|
# ===============
|
|
|
|
# = Social APIs =
|
|
|
|
# ===============
|
|
|
|
|
|
|
|
FACEBOOK_APP_ID = '111111111111111'
|
|
|
|
FACEBOOK_SECRET = '99999999999999999999999999999999'
|
2012-10-16 13:40:27 -07:00
|
|
|
FACEBOOK_NAMESPACE = 'newsblur'
|
2011-12-21 09:43:17 -08:00
|
|
|
TWITTER_CONSUMER_KEY = 'ooooooooooooooooooooo'
|
|
|
|
TWITTER_CONSUMER_SECRET = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
|
2011-12-20 11:49:49 -08:00
|
|
|
|
2012-09-18 17:09:07 -07:00
|
|
|
# ===============
|
|
|
|
# = AWS Backing =
|
|
|
|
# ===============
|
|
|
|
|
2013-04-28 21:39:40 -07:00
|
|
|
ORIGINAL_PAGE_SERVER = "db01:3060"
|
2012-12-14 16:28:06 -08:00
|
|
|
|
2012-09-18 17:09:07 -07:00
|
|
|
BACKED_BY_AWS = {
|
|
|
|
'pages_on_s3': False,
|
|
|
|
'icons_on_s3': False,
|
|
|
|
}
|
|
|
|
|
2012-09-19 12:15:05 -07:00
|
|
|
PROXY_S3_PAGES = True
|
2012-09-20 12:29:52 -07:00
|
|
|
S3_BACKUP_BUCKET = 'newsblur_backups'
|
|
|
|
S3_PAGES_BUCKET_NAME = 'pages.newsblur.com'
|
|
|
|
S3_ICONS_BUCKET_NAME = 'icons.newsblur.com'
|
2013-01-08 14:11:59 -08:00
|
|
|
S3_AVATARS_BUCKET_NAME = 'avatars.newsblur.com'
|
2012-09-19 12:15:05 -07:00
|
|
|
|
2010-04-05 00:47:21 -04:00
|
|
|
# ==================
|
|
|
|
# = Configurations =
|
|
|
|
# ==================
|
2010-10-16 18:52:52 -04:00
|
|
|
try:
|
|
|
|
from gunicorn_conf import *
|
|
|
|
except ImportError, e:
|
|
|
|
pass
|
2012-07-16 23:40:17 -07:00
|
|
|
|
2010-04-05 00:47:21 -04:00
|
|
|
from local_settings import *
|
|
|
|
|
2013-04-27 14:26:53 -04:00
|
|
|
if not DEVELOPMENT:
|
|
|
|
INSTALLED_APPS += (
|
|
|
|
'gunicorn',
|
|
|
|
'raven.contrib.django',
|
2013-05-08 02:15:55 -07:00
|
|
|
'django_ses',
|
2013-04-27 14:26:53 -04:00
|
|
|
|
|
|
|
)
|
|
|
|
|
2010-04-05 00:47:21 -04:00
|
|
|
COMPRESS = not DEBUG
|
2010-04-06 20:41:00 -04:00
|
|
|
TEMPLATE_DEBUG = DEBUG
|
2010-04-09 18:30:25 -04:00
|
|
|
ACCOUNT_ACTIVATION_DAYS = 30
|
2011-09-21 22:08:53 -07:00
|
|
|
AWS_ACCESS_KEY_ID = S3_ACCESS_KEY
|
|
|
|
AWS_SECRET_ACCESS_KEY = S3_SECRET
|
2010-04-06 20:41:00 -04:00
|
|
|
|
2012-09-04 11:46:41 -07:00
|
|
|
os.environ["AWS_ACCESS_KEY_ID"] = AWS_ACCESS_KEY_ID
|
|
|
|
os.environ["AWS_SECRET_ACCESS_KEY"] = AWS_SECRET_ACCESS_KEY
|
|
|
|
|
2010-04-06 20:41:00 -04:00
|
|
|
def custom_show_toolbar(request):
|
|
|
|
return DEBUG
|
|
|
|
|
|
|
|
DEBUG_TOOLBAR_CONFIG = {
|
|
|
|
'INTERCEPT_REDIRECTS': True,
|
|
|
|
'SHOW_TOOLBAR_CALLBACK': custom_show_toolbar,
|
|
|
|
'HIDE_DJANGO_SQL': False,
|
2010-08-21 13:57:39 -04:00
|
|
|
}
|
2013-03-20 16:59:11 -05:00
|
|
|
if not DEVELOPMENT:
|
|
|
|
RAVEN_CLIENT = raven.Client(SENTRY_DSN)
|
2013-04-27 14:26:53 -04:00
|
|
|
EMAIL_BACKEND = 'django_ses.SESBackend'
|
2010-08-21 13:57:39 -04:00
|
|
|
|
2013-03-26 17:19:17 -07:00
|
|
|
if DEBUG:
|
|
|
|
TEMPLATE_LOADERS = (
|
|
|
|
('django.template.loaders.filesystem.Loader',
|
|
|
|
'django.template.loaders.app_directories.Loader',
|
|
|
|
),
|
|
|
|
)
|
|
|
|
else:
|
|
|
|
TEMPLATE_LOADERS = (
|
|
|
|
('django.template.loaders.cached.Loader', (
|
|
|
|
'django.template.loaders.filesystem.Loader',
|
|
|
|
'django.template.loaders.app_directories.Loader',
|
|
|
|
)),
|
|
|
|
)
|
|
|
|
|
2013-03-14 10:49:44 -07:00
|
|
|
# =========
|
|
|
|
# = Redis =
|
|
|
|
# =========
|
|
|
|
|
|
|
|
BROKER_BACKEND = "redis"
|
2013-06-18 12:21:27 -07:00
|
|
|
BROKER_URL = "redis://%s:6379/%s" % (REDIS['host'], CELERY_REDIS_DB)
|
2013-03-14 10:49:44 -07:00
|
|
|
CELERY_RESULT_BACKEND = BROKER_URL
|
|
|
|
|
2010-08-21 13:57:39 -04:00
|
|
|
# =========
|
|
|
|
# = Mongo =
|
|
|
|
# =========
|
|
|
|
|
2011-08-27 16:22:52 -07:00
|
|
|
MONGO_DB_DEFAULTS = {
|
|
|
|
'name': 'newsblur',
|
2012-03-26 17:04:35 -07:00
|
|
|
'host': 'db02:27017',
|
2012-09-06 17:16:01 -07:00
|
|
|
'alias': 'default',
|
2011-08-27 16:22:52 -07:00
|
|
|
}
|
|
|
|
MONGO_DB = dict(MONGO_DB_DEFAULTS, **MONGO_DB)
|
2012-10-29 12:25:28 -07:00
|
|
|
|
|
|
|
# if MONGO_DB.get('read_preference', pymongo.ReadPreference.PRIMARY) != pymongo.ReadPreference.PRIMARY:
|
|
|
|
# MONGO_PRIMARY_DB = MONGO_DB.copy()
|
|
|
|
# MONGO_PRIMARY_DB.update(read_preference=pymongo.ReadPreference.PRIMARY)
|
|
|
|
# MONGOPRIMARYDB = connect(MONGO_PRIMARY_DB.pop('name'), **MONGO_PRIMARY_DB)
|
|
|
|
# else:
|
|
|
|
# MONGOPRIMARYDB = MONGODB
|
2011-08-27 16:22:52 -07:00
|
|
|
MONGODB = connect(MONGO_DB.pop('name'), **MONGO_DB)
|
2011-11-05 17:08:31 -07:00
|
|
|
|
2012-09-06 17:16:01 -07:00
|
|
|
MONGO_ANALYTICS_DB_DEFAULTS = {
|
|
|
|
'name': 'nbanalytics',
|
2013-06-18 13:22:31 -07:00
|
|
|
'host': 'db30:27017',
|
2012-09-06 17:16:01 -07:00
|
|
|
'alias': 'nbanalytics',
|
|
|
|
}
|
|
|
|
MONGO_ANALYTICS_DB = dict(MONGO_ANALYTICS_DB_DEFAULTS, **MONGO_ANALYTICS_DB)
|
|
|
|
MONGOANALYTICSDB = connect(MONGO_ANALYTICS_DB.pop('name'), **MONGO_ANALYTICS_DB)
|
|
|
|
|
2012-10-29 12:25:28 -07:00
|
|
|
|
2011-11-05 17:08:31 -07:00
|
|
|
# =========
|
|
|
|
# = Redis =
|
|
|
|
# =========
|
|
|
|
|
2011-11-06 15:20:30 -08:00
|
|
|
REDIS_POOL = redis.ConnectionPool(host=REDIS['host'], port=6379, db=0)
|
2012-07-15 22:51:27 -07:00
|
|
|
REDIS_ANALYTICS_POOL = redis.ConnectionPool(host=REDIS['host'], port=6379, db=2)
|
2013-03-25 11:10:36 -07:00
|
|
|
REDIS_STATISTICS_POOL = redis.ConnectionPool(host=REDIS['host'], port=6379, db=3)
|
2013-03-30 12:41:03 -07:00
|
|
|
REDIS_FEED_POOL = redis.ConnectionPool(host=REDIS['host'], port=6379, db=4)
|
2013-03-20 19:45:39 -07:00
|
|
|
REDIS_SESSION_POOL = redis.ConnectionPool(host=REDIS['host'], port=6379, db=5)
|
2013-04-08 13:09:43 -07:00
|
|
|
# REDIS_CACHE_POOL = redis.ConnectionPool(host=REDIS['host'], port=6379, db=6) # Duped in CACHES
|
2013-04-13 22:31:05 -07:00
|
|
|
REDIS_STORY_HASH_POOL = redis.ConnectionPool(host=REDIS['host'], port=6379, db=8)
|
2011-11-07 08:48:00 -08:00
|
|
|
|
2013-06-18 12:21:27 -07:00
|
|
|
REDIS_PUBSUB_POOL = redis.ConnectionPool(host=REDIS2['host'], port=6379, db=0)
|
|
|
|
|
|
|
|
# ==========
|
|
|
|
# = Assets =
|
|
|
|
# ==========
|
|
|
|
|
2012-01-14 10:59:10 -08:00
|
|
|
JAMMIT = jammit.JammitAssets(NEWSBLUR_DIR)
|
2012-04-06 18:28:26 -07:00
|
|
|
|
|
|
|
if DEBUG:
|
2012-04-06 18:35:40 -07:00
|
|
|
MIDDLEWARE_CLASSES += ('utils.mongo_raw_log_middleware.SqldumpMiddleware',)
|
2012-07-25 17:55:23 -07:00
|
|
|
MIDDLEWARE_CLASSES += ('utils.redis_raw_log_middleware.SqldumpMiddleware',)
|
2012-07-28 13:16:18 -07:00
|
|
|
MIDDLEWARE_CLASSES += ('utils.request_introspection_middleware.DumpRequestMiddleware',)
|
2012-08-24 18:07:44 -07:00
|
|
|
MIDDLEWARE_CLASSES += ('utils.exception_middleware.ConsoleExceptionMiddleware',)
|
2012-07-16 23:40:17 -07:00
|
|
|
|
2013-05-08 12:13:26 -07:00
|
|
|
# ============
|
|
|
|
# = Haystack =
|
|
|
|
# ============
|
|
|
|
|
|
|
|
HAYSTACK_CONNECTIONS = {
|
|
|
|
'default': {
|
|
|
|
'ENGINE': 'haystack.backends.elasticsearch_backend.ElasticsearchSearchEngine',
|
2013-05-08 12:14:50 -07:00
|
|
|
'URL': 'http://%s' % ELASTICSEARCH_HOSTS[0],
|
2013-05-08 12:13:26 -07:00
|
|
|
'INDEX_NAME': 'haystack',
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
2012-09-18 17:09:07 -07:00
|
|
|
# =======
|
|
|
|
# = AWS =
|
|
|
|
# =======
|
|
|
|
|
|
|
|
S3_CONN = None
|
|
|
|
if BACKED_BY_AWS.get('pages_on_s3') or BACKED_BY_AWS.get('icons_on_s3'):
|
|
|
|
S3_CONN = S3Connection(S3_ACCESS_KEY, S3_SECRET)
|
2012-12-10 11:13:45 -08:00
|
|
|
if BACKED_BY_AWS.get('pages_on_s3'):
|
|
|
|
S3_PAGES_BUCKET = S3_CONN.get_bucket(S3_PAGES_BUCKET_NAME)
|
|
|
|
if BACKED_BY_AWS.get('icons_on_s3'):
|
|
|
|
S3_ICONS_BUCKET = S3_CONN.get_bucket(S3_ICONS_BUCKET_NAME)
|
2013-03-20 17:00:58 -07:00
|
|
|
|
2013-03-25 12:32:15 -07:00
|
|
|
django.http.request.host_validation_re = re.compile(r"^([a-z0-9.-_\-]+|\[[a-f0-9]*:[a-f0-9:]+\])(:\d+)?$")
|