Skip to content
Extraits de code Groupes Projets
Valider a06c58ee rédigé par Jamesie Pic's avatar Jamesie Pic
Parcourir les fichiers

Removed dependency to redis

parent 22519fc3
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -35,12 +35,12 @@ To deploy the website, use a command like:: ...@@ -35,12 +35,12 @@ To deploy the website, use a command like::
$ rhc app-create \ $ rhc app-create \
python-2.7 \ python-2.7 \
"http://cartreflect-claytondev.rhcloud.com/reflect?github=smarterclayton/openshift-redis-cart" \
cron-1.4 \ cron-1.4 \
postgresql-9.2 \ postgresql-9.2 \
-a yourappname \ -a yourappname \
-e OPENSHIFT_PYTHON_WSGI_APPLICATION=memopol/wsgi.py \ -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 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 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 = ( ...@@ -78,6 +78,7 @@ INSTALLED_APPS = (
'compressor', 'compressor',
'adminplus', 'adminplus',
'constance', 'constance',
'constance.backends.database',
'bootstrap3', 'bootstrap3',
'datetimewidget', 'datetimewidget',
'django_filters', 'django_filters',
...@@ -281,20 +282,7 @@ if os.path.exists(RAVEN_FILE): ...@@ -281,20 +282,7 @@ if os.path.exists(RAVEN_FILE):
'dsn': f.read().strip() 'dsn': f.read().strip()
} }
CONSTANCE_BACKEND = 'constance.backends.redisd.RedisBackend' CONSTANCE_BACKEND = 'constance.backends.database.DatabaseBackend'
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_CONFIG = { CONSTANCE_CONFIG = {
'USE_COUNTRY': (True, 'Use country for representative'), 'USE_COUNTRY': (True, 'Use country for representative'),
......
...@@ -11,7 +11,7 @@ django-adminplus ...@@ -11,7 +11,7 @@ django-adminplus
requests requests
django-celery django-celery
django-denorm django-denorm
django-constance django-constance[database]
django-bootstrap3 django-bootstrap3
django-filter django-filter
django-taggit django-taggit
...@@ -20,6 +20,5 @@ django-datetime-widget ...@@ -20,6 +20,5 @@ django-datetime-widget
-e git+https://github.com/political-memory/django-representatives-votes.git@parltrack#egg=django-representatives-votes -e git+https://github.com/political-memory/django-representatives-votes.git@parltrack#egg=django-representatives-votes
django-extensions django-extensions
django-debug-toolbar django-debug-toolbar
redis
djangorestframework djangorestframework
django-autocomplete-light django-autocomplete-light
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter