Permalink
Browse files

refactor for new deployment

  • Loading branch information...
Matthew Pontefract
Matthew Pontefract committed Dec 4, 2011
1 parent 2e473d1 commit ba62a90207ab1a4a11e20176a6fa2e39d0f90a95
View
@@ -1,5 +1,6 @@
*.pyc
.pydevproject
.project
-config/*.json
+**.json
.*.swp
+local.py
View
@@ -22,7 +22,7 @@ should be installed in advance)
$ cd redflash
$ pip install -E .. -r requirements.txt
-4) Edit database and SMS gateway details in config/settings.py. For test purposes
+4) Edit database and SMS gateway details in local.py (copy basis for this from settings.py). For test purposes
comment out the ClickatellGateway and uncomment the DummyGateway (this is forced
automatically when the test suite is run)
@@ -45,17 +45,16 @@ should be installed in advance)
Local configuration
===================
-The file /etc/redflash.py is imported by settings.py at the end so can be used
+The file /etc/redflash/redflash_conf.py and local.py are imported by settings.py at the end so can be used
to override any settings on a per-host basis. You can, for example, put your
Clickatell user and password in there.
Testing with the Python client
==============================
-In the ext directory you will find redflash.py which contains a Python client wrapper. Put
-on your Python path and use as follows:
+Install the Redflash client from git://github.com/aquamatt/rfclient.git and use as follows::
- from redflash import RedFlashClient
+ from rfclient.redflash import RedFlashClient
rfc = RedFlashClient(rf_url = 'http://REDFLASH.SERVER.ADDRESS', api_key = 'A KEY FROM THE APIUser MODEL')
rfc.notify_contact('contact-slug', 'message')
View
@@ -84,8 +84,8 @@ this should not be used as a production solution for SMS.
Clients simply call on the RESTful(ish) API sketched out below. If you have Clickatel sending confirmation receipts, it should
be configured to call the ``/ack`` URL.
-An example Python client library is included in the ``ext`` directory. It is packaged with distutils and the latest tarball is
-also in the repo. ``pip install`` it and then::
+An example Python client library can be installed from git://github.com/aquamatt/rfclient.git.
+It is packaged with distutils. ``pip install`` it and then::
from rfclient.redflash import RedFlashClient
rfc = RedFlashClient(rf_url="http://my.redflash.url", api_key="<key obtained from admin>")
File renamed without changes.
File renamed without changes.
@@ -3,26 +3,19 @@
import os
import sys
-# we want a few paths on the python path
-# first up we add the root above the application so
-# we can have absolute paths everywhere
-python_path = os.path.join(
- os.path.realpath(os.path.dirname(__file__)), '../'
-)
# we have have a local apps directory
apps_path = os.path.join(
- os.path.realpath(os.path.dirname(__file__)), '../apps'
+ os.path.realpath(os.path.dirname(__file__)), 'apps'
)
# we have have a local externals directory
# which saves you having to install a load of
# python modules locally and get into a versioning
# issue
ext_path = os.path.join(
- os.path.realpath(os.path.dirname(__file__)), '../ext'
+ os.path.realpath(os.path.dirname(__file__)), 'ext'
)
# we add them first to avoid any collisions
-sys.path.insert(0, python_path)
sys.path.insert(0, apps_path)
sys.path.insert(0, ext_path)
@@ -9,12 +9,11 @@
import os
import sys
-sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), "../")))
-sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), "../apps")))
-sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), "../ext")))
+sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), "apps")))
+sys.path.insert(0, os.path.abspath(os.path.dirname(os.path.dirname(__file__))))
-os.environ["DJANGO_SETTINGS_MODULE"] = "config.settings"
+os.environ["DJANGO_SETTINGS_MODULE"] = "redflash.settings"
from django.core.handlers.wsgi import WSGIHandler
application = WSGIHandler()
@@ -4,6 +4,8 @@
# Django settings for RedFlash project.
import os
+import sys
+
SITE_ROOT = os.path.dirname(os.path.dirname(os.path.dirname(os.path.realpath(__file__))))
######################### GATEWAY CONFIGS ##############################
@@ -114,7 +116,7 @@
'debug_toolbar.middleware.DebugToolbarMiddleware',
)
-ROOT_URLCONF = 'config.urls'
+ROOT_URLCONF = 'urls'
TEMPLATE_DIRS = (
# Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
@@ -140,12 +142,18 @@
from celery_conf import *
-# Allow overrides in a /etc/redflash.py config file
-try:
- import sys
- sys.path.insert(0, '/etc')
+# host overrides
+if os.path.exists("/etc/redflash/redflash_conf.py") \
+ or os.path.exists("/etc/redflash/redflash_conf"):
+ sys.path.insert(0, "/etc/redflash")
+ from redflash_conf import *
+
+# backwards compatibility: previous versions put redflash_conf.py in /etc
+if os.path.exists("/etc/redflash_conf.py"):
+ sys.path.insert(0, "/etc")
from redflash_conf import *
+
+try:
+ from local import *
except ImportError:
pass
-
-
File renamed without changes.
File renamed without changes.

0 comments on commit ba62a90

Please sign in to comment.