Commit a06c58ee authored by Jamesie Pic's avatar Jamesie Pic

Removed dependency to redis

parent 22519fc3
......@@ -35,12 +35,12 @@ To deploy the website, use a command like::
$ rhc app-create \
python-2.7 \
"http://cartreflect-claytondev.rhcloud.com/reflect?github=smarterclayton/openshift-redis-cart" \
cron-1.4 \
postgresql-9.2 \
-a yourappname \
-e OPENSHIFT_PYTHON_WSGI_APPLICATION=memopol/wsgi.py \
--from-code https://github.com/political-memory/political_memory.git
--from-code https://github.com/political-memory/political_memory.git \
--no-git
This should create an app on openshift. Other commands would deploy it at once
but in this tutorial we're going to see how to manage it partly manually for
......
# coding: utf-8
# This file is part of memopol.
#
# memopol is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of
# the License, or any later version.
#
# memopol is distributed in the hope that it will
# be useful, but WITHOUT ANY WARRANTY; without even the implied
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU General Affero Public
# License along with django-representatives.
# If not, see <http://www.gnu.org/licenses/>.
#
# Copyright (C) 2015 Arnaud Fabre <af@laquadrature.net>
from __future__ import absolute_import
from celery import shared_task
from .models import MemopolRepresentative
@shared_task
def representatives_update_all():
'''
Call MemopolRepresentative.update_all methods
'''
for representative in MemopolRepresentative.objects.all():
representative.update_all()
# coding: utf-8
# This file is part of memopol.
#
# memopol is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of
# the License, or any later version.
#
# memopol is distributed in the hope that it will
# be useful, but WITHOUT ANY WARRANTY; without even the implied
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU General Affero Public
# License along with django-representatives.
# If not, see <http://www.gnu.org/licenses/>.
#
# Copyright (C) 2015 Arnaud Fabre <af@laquadrature.net>
from __future__ import absolute_import
# This will make sure the app is always imported when
# Django starts so that shared_task will use this app.
try:
import celery
except ImportError:
pass
else:
from .celery import app as celery_app
# coding: utf-8
# This file is part of memopol.
#
# memopol is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of
# the License, or any later version.
#
# memopol is distributed in the hope that it will
# be useful, but WITHOUT ANY WARRANTY; without even the implied
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU General Affero Public
# License along with django-representatives.
# If not, see <http://www.gnu.org/licenses/>.
#
# Copyright (C) 2015 Arnaud Fabre <af@laquadrature.net>
from __future__ import absolute_import
import os
from django.conf import settings
from celery import Celery
# set the default Django settings module for the 'celery' program.
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'memopol.settings')
app = Celery(
'memopol',
broker='redis://localhost/{}'.format(settings.REDIS_DB),
backend='redis://localhost/{}'.format(settings.REDIS_DB)
)
# Using a string here means the worker will not have to
# pickle the object when using Windows.
app.config_from_object('django.conf:settings')
app.autodiscover_tasks(lambda: settings.INSTALLED_APPS)
@app.task(bind=True)
def debug_task(self):
print('Request: {0!r}'.format(self.request))
......@@ -78,6 +78,7 @@ INSTALLED_APPS = (
'compressor',
'adminplus',
'constance',
'constance.backends.database',
'bootstrap3',
'datetimewidget',
'django_filters',
......@@ -281,20 +282,7 @@ if os.path.exists(RAVEN_FILE):
'dsn': f.read().strip()
}
CONSTANCE_BACKEND = 'constance.backends.redisd.RedisBackend'
CONSTANCE_REDIS_CONNECTION = {
'host': os.environ.get('OPENSHIFT_REDIS_HOST', 'localhost'),
'port': os.environ.get('OPENSHIFT_REDIS_PORT', 6379),
'password': os.environ.get('REDIS_PASSWORD', ''),
'db': 1,
}
CONSTANCE_REDIS_CONNECTION = 'redis://:%s@%s:%s/%s' % (
os.environ.get('REDIS_PASSWORD', ''),
os.environ.get('OPENSHIFT_REDIS_HOST', 'localhost'),
os.environ.get('OPENSHIFT_REDIS_PORT', 6379),
0,
)
CONSTANCE_BACKEND = 'constance.backends.database.DatabaseBackend'
CONSTANCE_CONFIG = {
'USE_COUNTRY': (True, 'Use country for representative'),
......
......@@ -11,7 +11,7 @@ django-adminplus
requests
django-celery
django-denorm
django-constance
django-constance[database]
django-bootstrap3
django-filter
django-taggit
......@@ -20,6 +20,5 @@ django-datetime-widget
-e git+https://github.com/political-memory/django-representatives-votes.git@parltrack#egg=django-representatives-votes
django-extensions
django-debug-toolbar
redis
djangorestframework
django-autocomplete-light
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