Difference between revisions of "Academy"

From Jon's Wiki
 
Line 33: Line 33:
 
=== Running the github version of Mezzanine ===
 
=== Running the github version of Mezzanine ===
  
The instructions assume you're not a hacker wanting to work on the codebase. Consequently, we need to wire up the github version. First, get the bin directory on your path, so at your shell prompt:
+
The instructions assume you're not a hacker wanting to work on the codebase. Consequently, we need to wire up the github version. We need to get the Mezzanine bin directory on your path, and the Mezzanine project directory into Python's include path. At your shell prompt:
  
 
  export PATH=/home/''USERNAME''/mezzanine-env/mezzanine/mezzanine/bin:$PATH
 
  export PATH=/home/''USERNAME''/mezzanine-env/mezzanine/mezzanine/bin:$PATH
 +
export PYTHONPATH=/home/''USERNAME''/mezzanine-env/mezzanine:$PYTHONPATH
  
Then, we're going to hack-a-saurus a wee shell script in <code>~/mezzanine-env/mezzanine/bin/mezzanine-project</code>:
+
Then, we're going to hack-a-saurus a wee shell script in <code>~/mezzanine-env/mezzanine/mezzanine/bin/mezzanine-project</code>:
  
 
  #!/bin/sh
 
  #!/bin/sh
Line 45: Line 46:
 
Then make it executable:
 
Then make it executable:
  
  chmod +x ~/mezzanine-env/mezzanine/bin/mezzanine-project
+
  chmod +x ~/mezzanine-env/mezzanine/mezzanine/bin/mezzanine-project
  
 
Now you should be able to create your own new Mezzanine project, inside your Python virtual environment:
 
Now you should be able to create your own new Mezzanine project, inside your Python virtual environment:
Line 51: Line 52:
 
  cd ~/mezzanine-env
 
  cd ~/mezzanine-env
 
  mezzanine-project hogwarts-blog
 
  mezzanine-project hogwarts-blog
 
Now, we need something in PYTHONPATH so that Python knows where to find Mezzanine:
 
 
export PYTHONPATH=/home/$USER/mezzanine-env/mezzanine:$PYTHONPATH
 
  
 
Now we can use manage.py to run the project:
 
Now we can use manage.py to run the project:
Line 60: Line 57:
 
  cd hogwarts-blog
 
  cd hogwarts-blog
 
  python manage.py createdb
 
  python manage.py createdb
  python manage.py runserver
+
  python manage.py runserver 0.0.0.0:8000
  
 
Now go to http://127.0.0.1:8000/ in your browser!
 
Now go to http://127.0.0.1:8000/ in your browser!

Latest revision as of 04:25, 15 January 2013

Hizees! We're going to hack on Mezzanine, a Django Content Management System (CMS).

Install Mezzanine

Firstly, install and start a Python virtual environment:

sudo apt-get install python-virtualenv

once installed, create an environment for Mezzanine:

cd ~
virtualenv mezzanine-env
cd mezzanine-env
source bin/activate

You should now be in a Python virtual environment. This will isolate your Python libraries from the system's ones in case stuff breaks. Now install some dependencies:

sudo apt-get install python-dev
pip install django pil filebrowser-safe bleach grappelli-safe django-compressor pytz pyflakes pep8

Then grab it from github:

git clone https://github.com/stephenmcd/mezzanine.git

You should have a directory structure something like:

~
|
|__ mezzanine-env      - the Python virtual environment
    |
    |__ mezzanine      - the Mezzanine application (cloned from github)

Running the github version of Mezzanine

The instructions assume you're not a hacker wanting to work on the codebase. Consequently, we need to wire up the github version. We need to get the Mezzanine bin directory on your path, and the Mezzanine project directory into Python's include path. At your shell prompt:

export PATH=/home/USERNAME/mezzanine-env/mezzanine/mezzanine/bin:$PATH
export PYTHONPATH=/home/USERNAME/mezzanine-env/mezzanine:$PYTHONPATH

Then, we're going to hack-a-saurus a wee shell script in ~/mezzanine-env/mezzanine/mezzanine/bin/mezzanine-project:

#!/bin/sh
export PYTHONPATH=/home/USERNAME/mezzanine-env/mezzanine:$PYTHONPATH
python $(dirname $0)/mezzanine_project.py $*

Then make it executable:

chmod +x ~/mezzanine-env/mezzanine/mezzanine/bin/mezzanine-project

Now you should be able to create your own new Mezzanine project, inside your Python virtual environment:

cd ~/mezzanine-env
mezzanine-project hogwarts-blog

Now we can use manage.py to run the project:

cd hogwarts-blog
python manage.py createdb
python manage.py runserver 0.0.0.0:8000

Now go to http://127.0.0.1:8000/ in your browser!