From 9169063f7d9cac71b1c2f5de88725756cbeec511 Mon Sep 17 00:00:00 2001 From: sanj Date: Thu, 20 May 2010 00:41:25 +0530 Subject: [PATCH] inital project layout --- .bzrignore | 9 +++++++++ README | 21 +++++++++++++++++++++ fabfile.py | 46 ++++++++++++++++++++++++++++++++++++++++++++++ requirements.txt | 3 +++ wsgi/django.wsgi | 27 +++++++++++++++++++++++++++ 5 files changed, 106 insertions(+) create mode 100644 .bzrignore create mode 100644 README create mode 100644 fabfile.py create mode 100644 requirements.txt create mode 100644 wsgi/django.wsgi diff --git a/.bzrignore b/.bzrignore new file mode 100644 index 0000000..9e6e4a0 --- /dev/null +++ b/.bzrignore @@ -0,0 +1,9 @@ +bin +include +lib +src +build +dev.sqlite +secret.txt +local_settings.py +pip-log.txt diff --git a/README b/README new file mode 100644 index 0000000..06c7d83 --- /dev/null +++ b/README @@ -0,0 +1,21 @@ +campers + +Get: + bzr branch PUBLIC_URL campers + cd campers + virtualenv . + pip -E . install -r requirements.txt + +Develop: + create campers/local_settings.py + + . bin/activate + cd campers + python manage.py shell + + python manage.py runserver + +Deploy: + create campers/local_settings.py + + create /etc/apache2/sites-availavle/sitename.conf diff --git a/fabfile.py b/fabfile.py new file mode 100644 index 0000000..ed7b161 --- /dev/null +++ b/fabfile.py @@ -0,0 +1,46 @@ +#this is a fabfile, use it with fab from http://fabfile.org/ +# +# initial setup: +# fab production setup +# +# deploy changes: +# fab production deploy +# + +from os.path import join +from fabric.api import run, local, sudo, put, env + +env.project_name = 'campers' + +def production(): + env.hosts = ['%(project_name)s@camp.r-w-x.org'%env, ] + env.project_root = '/srv/%(project_name)s'%env + +def bzr_push(): + local('bzr push bzr+ssh://%(project_name)s@%(host)s%(project_root)s'%env) + +def bzr_update(): + run('cd %(project_root)s;bzr update'%env) + +def virtual_run(cmd, *a, **kw): + cmd = 'cd %s; source bin/activate; %s' % (env.project_root, cmd) + run(cmd, *a, **kw) + +def update_requirements(): + run('pip -E %(project_root)s install -r %(project_root)s/requirements.txt'%env) + +def setup(): + """ + Setup a fresh virtualenv + """ + local('bzr push --use-existing-dir bzr+ssh://%(project_name)s@%(host)s%(project_root)s'%env) + run('cd %(project_root)s; test -e .bzr/checkout || bzr checkout'%env) + run('virtualenv %(project_root)s'%env) + put(join('settings', '%(host)s.py'%env), join(env.project_root, env.project_name, 'local_settings.py')) + update_requirements() + +def deploy(): + bzr_push() + bzr_update() + virtual_run('python %(project_root)s/%(project_name)s/manage.py syncdb;python %(project_root)s/%(project_name)s/manage.py migrate'%env) + run('touch %(project_root)s/wsgi/django.wsgi'%env) diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..681494b --- /dev/null +++ b/requirements.txt @@ -0,0 +1,3 @@ +-e svn+http://code.djangoproject.com/svn/django/branches/releases/1.1.X#egg=django +-e bzr+http://code.0xdb.org/python-oxdjango/#egg=python-oxdjango +South diff --git a/wsgi/django.wsgi b/wsgi/django.wsgi new file mode 100644 index 0000000..21291ea --- /dev/null +++ b/wsgi/django.wsgi @@ -0,0 +1,27 @@ +# django.wsgi for campers +import os +import sys +import site + +project_module = 'campers' + +root_dir = os.path.normpath(os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))) + +#using virtualenv's activate_this.py to reorder sys.path +activate_this = os.path.join(root_dir, 'bin', 'activate_this.py') +execfile(activate_this, dict(__file__=activate_this)) + +sys.path.append(root_dir) +sys.path.append(os.path.join(root_dir, project_module)) + +#reload if this django.wsgi gets touched +from oxdjango import monitor +monitor.start(interval=1.0) + +monitor.track(os.path.abspath(os.path.dirname(__file__))) + +os.environ['DJANGO_SETTINGS_MODULE'] = project_module + '.settings' + +import django.core.handlers.wsgi + +application = django.core.handlers.wsgi.WSGIHandler()