Pinax's New Directory Structure

Posted on in Programming

If you've been following along, you are probably already aware the Pinax team has decided to make some radical changes to their directory structure based on input from users. I took the time to update my own Pinax project — let me show you what's changed.

First, here's the new directory structure, straight from the README file:

projects/
    complete_project/   a complete sample project and templates
    basic_project/      a more basic starter project (still to come)
apps/
    external_apps/      external re-usable apps via svn:externals
    local_apps/         re-usable apps that aren't yet externalized
    core_apps/          non re-usable apps specific to sample project
libs/
    external_libs/      external libraries
docs/                   documentation (in progress)
fixtures/               test fixtures (in progress)

As you can see, the application directories have been put into their own structure and a directory for libraries was added. Basically, the space is less flat now.

The projects directory contains sample projects. The manage.py executable in these project directories are designed to automatically include the previously mentioned library and application directories in the appropriate paths.

I've already made the changes to my project to include the new directory structure. What I've done is removed the top level externals (core_apps, external_apps, external_libs, local_apps) and replaced the with two new externals: apps and libs.

Once that was done, I edited my manage.py to accommodate the new directories. Here's a unified diff to give you an idea.

Index: manage.py
===================================================================
--- manage.py   (revision 31)
+++ manage.py   (working copy)
@@ -2,11 +2,11 @@
 from os.path import abspath, dirname, join
 from site import addsitedir
 import sys
-path = addsitedir(abspath(join(dirname(__file__), '../external_libs')), set())
+path = addsitedir(abspath(join(dirname(__file__), '../libs/external_libs')), set())
 if path: sys.path = list(path) + sys.path
-sys.path.insert(0, abspath(join(dirname(__file__), '../external_apps')))
-sys.path.insert(0, abspath(join(dirname(__file__), '../local_apps')))
-sys.path.insert(0, abspath(join(dirname(__file__), '../core_apps')))
+sys.path.insert(0, abspath(join(dirname(__file__), '../apps/external_apps')))
+sys.path.insert(0, abspath(join(dirname(__file__), '../apps/local_apps')))
+sys.path.insert(0, abspath(join(dirname(__file__), '../apps/core_apps')))

 from django.core.management import execute_manager
 try:

The paradigm moving forward is probably going to be to create your new projects in the project directory. If that ends up being the best way to go, we'll cross that bridge when we get to it. For now, this setup is working for us.

Slaptijack's Koding Kraken