grappelli installed + installation process tuning

This commit is contained in:
zalun 2010-01-24 13:49:12 +00:00
Родитель 38a83dd49b
Коммит 425f5fcba4
17 изменённых файлов: 199 добавлений и 75 удалений

73
INSTALL
Просмотреть файл

@ -3,30 +3,33 @@ First Installation
Virtualenv is providing a stable environment for Django. (1)
Assuming Python 2.5+ is already installed it should be enough to follow these
steps (some commands are specific to Ubuntu with Bash):
Assuming that svn/git/mercurial and Python 2.5+ is already
installed it should be enough to follow these steps (some
commands are specific to Ubuntu with Bash):
1. Clone FlightDeck from github
$ cd /path/to/projects/
$ git clone git@github.com:zalun/FlightDeck.git
2. Install python-setuptools python-dev build-essential
$ sudo apt-get install python-setuptools python-dev build-essential
2. Initiate configuration files
$ cd /path/to/projects/FlightDeck
$ ./scripts/initiate.sh
3. Install Pip and VirtualEnv
3. Install python-setuptools python-dev build-essential libmysqlclient-dev
$ sudo apt-get install python-setuptools python-dev build-essential libmysqlclient-dev
4. Install Pip and VirtualEnv
$ sudo easy_install -U pip
$ sudo pip install -U virtualenv
4. Create directory for Python environments
5. Create directory for Python environments
$ sudo mkdir /srv; sudo mkdir /srv/python-environments
$ cd /srv/python-environments
$ sudo virtualenv --no-site-packages flightdeck
5. Clear PYTHONPATH (could be optional, but it's working for me)
$ export PYTHONPATH=
6. Install from requirements.txt (tested on EEE PC running Ubuntu)
$ sudo pip install -E flightdeck/ -r /path/to/projects/FlightDeck/tools/pip-requirements.txt
6. Install via pip from requirements.txt and custom packages
$ cd /path/to/project/FlightDeck
$ ./scripts/install.sh
7. Check if everything is working
* activate flightdeck environment
@ -55,22 +58,26 @@ steps (some commands are specific to Ubuntu with Bash):
yolk==0.4.1
8. Configure the Django application
$ cd /path/to/projects/FlightDeck
$ ./scripts/install.sh
$ vi flightdeck/settings_local.py # **
9. Initiate database*
$ ./scripts/syncdb.sh
9. Check local scripts configuration
$ vi scripts/config_local.sh
9. Run Server*
10. Initiate database*
$ ./scripts/syncdb.sh
Choose your superadmin username and password
11. Run Server*
$ ./scripts/runserver.sh
FlightDeck may be accessed by loading http://127.0.0.1:8090/
FlightDeck may be accessed by loading http://localhost:8090/
Administration from http://localhost:8090/admin/
##############################
Extending the Python codebase
1. Install the package
1. Install the package (example of installing PIL - graphics operations for Python)
$ cd /srv/python-environments
$ pip install -E flightdeck/ pil
@ -78,18 +85,36 @@ Extending the Python codebase
$ pip freeze -E flightdeck/ > /path/to/projects/FlightDeck/tools/pip-requirements.txt
##############################
Adding third party projects
DOC: http://pip.openplans.org/requirement-format.html
1. Install using subversion/git/mercurial if module configured as an egg (2)
# South is used as an example however we will use pip to install this module
# Change requirements
# add following line to FlightDeck/tools/pip-requirements.txt
# add line
-e hg+http://bitbucket.org/andrewgodwin/south/@0.6.2#egg=south
# update environment
$ cd /srv/python-environments
$ sudo pip install -E flightdeck/ -r /path/to/projects/FlightDeck/tools/pip-requirements.txt
2. Install custom packages
# Add to the scripts/install.sh
# checkout the right revisions into $SRC
sudo svn checkout http://django-grappelli.googlecode.com/svn/trunk/grappelli/ $SRC/grappelli
# Link module from #SRC to to $SITE_PACKAGES
if [ ! -e $SITE_PACKAGES/grappelli ]
then
$ sudo ln -fs $SRC/grappelli $SITE_PACKAGES/grappelli
fi
#####################
Updating requirements
Updating environment
1. Clear PYTHONPATH (could be optional, but it's working for me)
$ export PYTHONPATH=
2. Install from pip-requirements.txt
1. Install from pip-requirements.txt
$ cd /srv/python-environments
$ sudo pip install -E flightdeck/ -r /path/to/projects/FlightDeck/tools/pip-requirements.txt

Просмотреть файл

Просмотреть файл

@ -0,0 +1,3 @@
from django.db import models
# Create your models here.

23
flightdeck/base/tests.py Normal file
Просмотреть файл

@ -0,0 +1,23 @@
"""
This file demonstrates two different styles of tests (one doctest and one
unittest). These will both pass when you run "manage.py test".
Replace these with more appropriate tests for your application.
"""
from django.test import TestCase
class SimpleTest(TestCase):
def test_basic_addition(self):
"""
Tests that 1 + 1 always equals 2.
"""
self.failUnlessEqual(1 + 1, 2)
__test__ = {"doctest": """
Another way to test that 1 + 1 is equal to 2.
>>> 1 + 1 == 2
True
"""}

4
flightdeck/base/views.py Normal file
Просмотреть файл

@ -0,0 +1,4 @@
from django.http import Http404, HttpResponseRedirect, HttpResponse
def placeholder(req):
return HttpResponse("<h1>Hello World</h1>")

Просмотреть файл

@ -46,7 +46,7 @@ MEDIA_URL = ''
# URL prefix for admin media -- CSS, JavaScript and images. Make sure to use a
# trailing slash.
# Examples: "http://foo.com/media/", "/media/".
ADMIN_MEDIA_PREFIX = '/media/'
ADMIN_MEDIA_PREFIX = '/adminmedia/'
# Make this unique, and don't share it with anybody.
SECRET_KEY = 'somesecretkey'
@ -64,6 +64,11 @@ MIDDLEWARE_CLASSES = (
'django.contrib.auth.middleware.AuthenticationMiddleware',
)
TEMPLATE_CONTEXT_PROCESSORS = (
"django.core.context_processors.auth",
"django.core.context_processors.request",
)
ROOT_URLCONF = 'flightdeck.urls'
TEMPLATE_DIRS = (
@ -77,6 +82,12 @@ INSTALLED_APPS = (
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
# database migrations
'south',
# admin
# TODO: fix grappelli media
'grappelli',
'django.contrib.admin',
)
# overwrite default settings with the ones from settings_local.py

Просмотреть файл

@ -1,3 +1,8 @@
import os.path
import re
FRAMEWORK_PATH = os.path.dirname(os.path.dirname(__file__)) +'/'
ADMINS = (
# ('Your Name', 'your_email@domain.com'),
)
@ -15,3 +20,11 @@ SITE_ID = 1
MEDIA_ROOT = ''
MEDIA_URL = ''
SECRET_KEY = '_878&mu1t!-d*u^*@l$afwe$p4r(=*$kyyjy37ibf9t8li5#lv'
DEBUG = False
#MEDIA_ROOT = os.path.join(FRAMEWORK_PATH, '/flightdeck/media/')
#ADMIN_MEDIA_ROOT = os.path.join(FRAMEWORK_PATH, 'flightdeck/adminmedia/')
#MEDIA_URL = '/sitemedia/'
#MEDIA_SERVER = ''
#ADMIN_MEDIA_PREFIX = ''.join([MEDIA_SERVER,'/adminmedia/'])

Просмотреть файл

@ -1,17 +1,17 @@
from django.conf.urls.defaults import *
# Uncomment the next two lines to enable the admin:
# from django.contrib import admin
# admin.autodiscover()
from django.contrib import admin
admin.autodiscover()
urlpatterns = patterns('',
# Example:
# (r'^flightdeck/', include('flightdeck.foo.urls')),
(r'^/', include('flightdeck.urls_local')),
# Uncomment the admin/doc line below and add 'django.contrib.admindocs'
# to INSTALLED_APPS to enable admin documentation:
# (r'^admin/doc/', include('django.contrib.admindocs.urls')),
# grappelli
(r'^grappelli/', include('grappelli.urls')),
# Uncomment the next line to enable the admin:
# (r'^admin/', include(admin.site.urls)),
# admin
(r'^admin/doc/', include('django.contrib.admindocs.urls')),
(r'^admin/', include(admin.site.urls)),
)

Просмотреть файл

@ -0,0 +1,7 @@
from django.conf.urls.defaults import *
urlpatterns = patterns('flightdeck.base.views',
url(r'^$','placeholder', name='placeholder'),
)

3
scripts/config.sh Normal file
Просмотреть файл

@ -0,0 +1,3 @@
#!/bin/bash
PROJECT_NAME='flightdeck'

Просмотреть файл

@ -1,8 +1,9 @@
#!/bin/bash
source scripts/config_local.sh
# activate Python flightdeck environment
cd $PYTHON_ENVIRONMENTS_DIR
source $PYTHON_ENVIRONMENT/bin/activate
#cd $PYTHON_ENVIRONMENTS_DIR
source $V_ENV/bin/activate
# set path to the project direcotry
PYTHONPATH=$PROJECT_DIR:$PYTHONPATH

40
scripts/initiate.sh Executable file
Просмотреть файл

@ -0,0 +1,40 @@
#!/bin/bash
source scripts/config.sh
# copy configuration files to local
for loc in $PROJECT_NAME/*_local-default.py
do
if [ -e $PROJECT_NAME/`basename $loc "-default.py"`.py ]
then
echo file exists $PROJECT_NAME/`basename $loc "-default.py"`.py
else
cp $loc $PROJECT_NAME/`basename $loc "-default.py"`.py
echo $loc "->" $PROJECT_NAME/`basename $loc "-default.py"`.py
fi
done
for wsgi in apache/*_local-default.wsgi
do
if [ -e apache/`basename $wsgi "-default.wsgi"`.wsgi ]
then
echo file exists apache/`basename $wsgi "-default.wsgi"`.wsgi
else
cp $wsgi apache/`basename $wsgi "-default.wsgi"`.wsgi
echo $wsgi "->" apache/`basename $wsgi "-default.wsgi"`.wsgi
fi
done
for sh in scripts/*_local-default.sh
do
if [ -e scripts/`basename $sh "-default.sh"`.sh ]
then
echo file exists scripts/`basename $sh "-default.sh"`.sh
else
cp $sh scripts/`basename $sh "-default.sh"`.sh
echo $sh "->" scripts/`basename $sh "-default.sh"`.sh
fi
done
# force exclude local files
cp tools/git-exclude .git/info/exclude
echo tools/git-exclude "->" .git/info/exclude

Просмотреть файл

@ -1,39 +1,30 @@
#!/bin/bash
# copy configuration files to local
for loc in flightdeck/*_local-default.py
source scripts/config_local.sh
# src dir
SRC=$V_ENV/src
# find last python dir
for i in $V_ENV/lib/python*
do
if [ -e flightdeck/`basename $loc "-default.py"`.py ]
then
echo file exists flightdeck/`basename $loc "-default.py"`.py
else
cp $loc flightdeck/`basename $loc "-default.py"`.py
echo $loc "->" flightdeck/`basename $loc "-default.py"`.py
fi
SITE_PACKAGES=$i/site-packages
done
for wsgi in apache/*_local-default.wsgi
do
if [ -e apache/`basename $wsgi "-default.wsgi"`.wsgi ]
then
echo file exists apache/`basename $wsgi "-default.wsgi"`.wsgi
else
cp $wsgi apache/`basename $wsgi "-default.wsgi"`.wsgi
echo $wsgi "->" apache/`basename $wsgi "-default.wsgi"`.wsgi
fi
done
### PIP packages installation
export PYTHONPATH=
sudo pip install -E $V_ENV/ -r $PROJECT_DIR/tools/pip-requirements.txt
# TODO: write a proper bash script which will install from configurable files
for sh in scripts/*_local-default.sh
do
if [ -e scripts/`basename $sh "-default.sh"`.sh ]
### Grappelli section
# checkout the repository
sudo svn checkout http://django-grappelli.googlecode.com/svn/trunk/grappelli/ $SRC/grappelli
# link to site-packages
if [ ! -e $SITE_PACKAGES/grappelli ]
then
echo file exists scripts/`basename $sh "-default.sh"`.sh
else
cp $sh scripts/`basename $sh "-default.sh"`.sh
echo $sh "->" scripts/`basename $sh "-default.sh"`.sh
sudo ln -fs $SRC/grappelli $SITE_PACKAGES/grappelli
fi
# link adminmedia within project
if [ ! -e $PROJECT_DIR/$PROJECT_NAME/adminmedia ]
then
ln -fs $SRC/grappelli/media $PROJECT_DIR/$PROJECT_NAME/adminmedia
fi
done
# force exclude local files
cp tools/git-exclude .git/info/exclude
echo tools/git-exclude "->" .git/info/exclude

Просмотреть файл

@ -1,8 +1,7 @@
#!/bin/bash
source scripts/config_local.sh
source scripts/environment.sh
# run server
cd $PROJECT_DIR/flightdeck/
$PYTHON_COMMAND ./manage.py runserver 8090
cd $PROJECT_DIR/$PROJECT_NAME/
$PYTHON_COMMAND ./manage.py runserver localhost:8090 --adminmedia=$PROJECT_DIR/$PROJECT_NAME/adminmedia/

Просмотреть файл

@ -1,9 +1,8 @@
#!/bin/bash
source scripts/config_local.sh
source scripts/environment.sh
# run server
cd $PROJECT_DIR/flightdeck/
cd $PROJECT_DIR/$PROJECT_NAME/
$PYTHON_COMMAND ./manage.py syncdb

Просмотреть файл

@ -4,10 +4,12 @@
# exclude patterns (uncomment them if you want to use them):
# *.[oa]
# *~
logs
adminmedia
dev.db
pip-log.txt
*local.py
*local.wsgi
*local.sh
dev.db
logs
*.pyc
.*swp

Просмотреть файл

@ -1,4 +1,7 @@
Django==1.1.1
MySQL-python==1.2.3c1
PIL==1.1.7
South==0.6.2
docutils==0.6
wsgiref==0.1.2
yolk==0.4.1