OSQA on Heroku

processes

$ mkdir osqa
$ cd osqa

$ brew install mysql
$ unset TMPDIR
$ mysql_install_db --verbose --user=`whoami` --basedir="$(brew --prefix mysql)" --datadir=/usr/local/var/mysql --tmpdir=/tmp
$ mysql.server start
$ mysql -uroot
mysql> CREATE USER 'osqa'@'localhost' IDENTIFIED BY '***';
mysql> CREATE DATABASE osqa DEFAULT CHARACTER SET UTF8 COLLATE utf8_general_ci;
mysql> GRANT ALL ON osqa.* to 'osqa'@'localhost';

$ svn co http://svn.osqa.net/svnroot/osqa/trunk .
$ virtualenv venv --distribute
$ source ./venv/bin/activate
$ pip install South django==1.3 django-debug-toolbar mysql-python markdown html5lib python-openid gunicorn
$ cp settings_local.py.dist settings_local.py

$ emacs settings_local.py
import os.path
import os
import sys
import urlparse
...
↓消す
DATABASES = {
...
↓heroku 用の DB 設定を追加
# Register database schemes in URLs.
urlparse.uses_netloc.append('mysql')

try:

    # Check to make sure DATABASES is set in settings.py file.
    # If not default to {}

    if 'DATABASES' not in locals():
        DATABASES = {}

    if 'CLEARDB_DATABASE_URL' in os.environ:
        url = urlparse.urlparse(os.environ['CLEARDB_DATABASE_URL'])

        # Ensure default database exists.
        DATABASES['default'] = DATABASES.get('default', {})

        # Update with environment configuration.
        DATABASES['default'].update({
            'NAME': url.path[1:].split('?')[0],
            'USER': url.username,
            'PASSWORD': url.password,
            'HOST': url.hostname,
            'PORT': url.port,
        })
        if url.scheme == 'postgres':
            DATABASES['default']['ENGINE'] = 'django.db.backends.postgresql_psycopg2'

        if url.scheme == 'mysql':
            DATABASES['default']['ENGINE'] = 'django.db ...

Licenses