django
Installing django
Virtualenv
Univ_oahpa currently uses virutalenv to maintain all necessary dependent
Exceptional prerequisites
Univ_oahpa depends on python-mysql, which, depending on your system, will
With aptitude:
sudo apt-get install python-dev sudo apt-get install mysql-devel
With yum:
sudo yum install python-devel sudo yum install mysql-devel
Configuring a virtualenv for univ_oahpa
1. Check out the univ_oahpa source, and install virtualenv.
virtualenv path/to/env
3. Activate the virtual environment by sourcing its activation file:
. path/to/env/bin/activate
4. Locate requirements.txt within the univ_oahpa source branch, and run pip with it:
pip install -r path/to/requirements.txt
5. Have some coffee or tea.
GeoIP
univ_oahpa's user log also includes geographical information on each user interaction, and this is handled with GeoIP, which must be
For detailed install instructions see our GeoIP notes.
Install Django locally
To test applications and interfaces, install Django to your own
Go to gtoahpa (for the stable Oahpa versons) or to gtlab
$ mysql -u root -p mysql> GRANT all ON oahpa.* TO 'your-username'@'your-own-ip-address';
Edit the file ped/LANG_oahpa/settings.py (LANG being a variable for your
DATABASE_USER = 'your-username' DATABASE_PASSWORD = '' DATABASE_HOST = 'gtoahpa.uit.no' DATABASE_PORT = '' (port number)
And, finally, you need to create a language directory for the target language.
mkdir your_pythonlib/django/conf/locale/sme cp your_pythonlib/django/conf/locale/no/django.* $(djangopath)/django/conf/locale/sme/
Then start the web development server in your own computer:
cd ped/LANG_oahpa/ python manage.py runserver
The pages should be available in
In the sandbox, it is possible to test the changes to the code and to
Tronds notes on howto
This is how to do it on my machine
Check in the control panel that MySQL is running: Click on it and see the green running word.
MySQL browser
check that in $GTHOME/ped/LANG_oahpa/, the parameters are:
(to be filled in by a programmer)
Then start the web development server in your own computer:
cd $GTHOME/ped/LANG_oahpa/ python manage.py runserver
The pages should be available in
In the sandbox, it is possible to test the changes to the code and to
Some caveats with the local installation on MacOS:
- if you have two different python versions, both in
/usr/bin/python
and in
/opt/local/bin/python
you have to configure the Django installation as required (see, for instance, this site)
- if you have problems starting the sandbox web server and get the following error:
~/Django/someAppl>python manage.py runserver Validating models... Unhandled exception in thread started by <function inner_run at 0x6c1f70> Traceback (most recent call last): ............... from django.db import models, connection File "/opt/local/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/db/__init__.py", line 22, in <module> backend = __import__('%s.base' % settings.DATABASE_ENGINE, {}, {}, ['']) ImportError: No module named dummy.base
you might lack the py25-hashlib package
sudo port install py25-hashlib
Your own database
Sometimes it would be good idea to have a replicate also from the
Look at the file /etc/my.cnf. It should have these utf8-values:
[client] default-character-set=utf8 [mysqld] default-character-set=utf8 collation_server=utf8_bin character_set_server=utf8 character_set_client=utf8
Start the server with command:
sudo mysqld_safe &
Set root password and create a new user account:
mysqladmin -u root password "mypassword"
Look for manuals to create own user etc, but you may use the root as
mysql -u root -p mysql> create database oahpa character set utf8 collate utf8_bin; mysql> exit;
Change the local settings in ped/oahpa/settings.py:
DATABASE_USER = 'root' DATABASE_PASSWORD = 'myspassword' DATABASE_HOST = ''
Add the PYTHONPATH of the OAHPA! project in your .bashrc file:
export PYTHONPATH=$(YOUR-PATH-TO)/gtsvn/ped:$(YOUR-PATH-TO)/gtsvn/ped/oahpa:$(YOUR-PATH-TO)/gtsvn/ped/oahpa/drill
Adjust paths in ped/oahpa/ling.py:
fstdir="$(YOUR-PATH-TO)/gtsvn/gt/sme/bin" lookup = "$(YOUR-PATH-TO)/bin/lookup"
Adjust paths in ped/oahpa/drill/game.py:
fstdir="$(YOUR-PATH-TO)/gtsvn/gt/" + language + "/bin" lookup ="$(YOUR-PATH-TO)/bin/lookup"
Start installing the database information:
cd ped/oahpa python manage.py syncdb python install.py -r ../sme/src/paradigms.txt -t ../sme/src/tags.txt -b python install.py -r ../sme/src/paradigms.txt -t ../sme/src/tags.txt -f ../sme/xml/nouns.xml
Install everything you need starting from the lexicons.
Start Django locally:
python manage.py runserver
Possible problem:
- if you get a DB connection error, for instance
Can't connect to local MySQL server through socket '/var/mysql/mysql.sock'
first, find the mysql socket
~>mysqladmin variables | grep socket | socket | /tmp/mysql.sock
and then, change the value of the DATABASE_HOST in ped/oahpa/settings.py accordingly:
DATABASE_HOST = '/tmp/mysql.sock'