Skip to content

Wolfshead Software Blog

Some Random Programming Thoughts

Attempt number two.

1. Install Python 2.5.4 into C:\Python25.

2. Copy to the right folder (make sure you get the py2.5 version).

3. Add the line to the httpd.conf file (found in C:\Apache2\conf).

4. Copy the django folder from the svn downloaded copy into C:\Python25\Lib\site-packages make sure that both the Python folder (C:\Python25) the bin folder of the django folder you’ve just added are on the system path.

5. Test the installation as before (now proceed as previously).

6. Configure Apache to use the mod_wsgi module as in the “How to use django with Apache and mod_wsgi” section of the django documentation.

7. Copy the HolyFamily files to C:\djangoisms and point the mod_wsgi setting at the django.wsgi file there.

8. Copy the media files across into C:\Apache2\htdocs\.

9. Make sure the admin media alias in httpd.conf points to the right place (I need to double check this step).

10. Change the django.wsgi file in HolyFamily to point to the correct places.

11. Install the file MySQL-python-1.2.2.win32-py2.5.exe (the backend linking Python to our already installed MySQL database).

12. Create the Django Database and User for the installation.

13. Run the sql file which you have dumped from the development database to create the tables and entries.

14. Make sure points to the correct paths.

15. Install tagging.

16. We also need to add to the httpd.conf file the following to allow Apache to serve scripts from the folder which contains django.wsgi (this is the same folder which holds the site).

<Directory "C:/Path/To/Parent/Folder/Of/django.wsgi>
Order deny,allow
Allow from all

17. Enjoy!

The Holy Family site is now ready to be deployed, as I have not previously deployed a Django site, it seems appropriate to do a dry run first, so I shall document the steps necessary to install it on my windows laptop here. We already have a working Apache and PHP combination on both so we will start by installing Python, then mod_wsgi, and proceed to the django install.

1. Python, the latest version for which a windows binary of mod_wsgi exists is 2.6, so download 2.6.2 and install it to C:\Python26.

2. Copy the file to the C:\Apache2\modules\ folder and rename it to

3. Add the line LoadModule wsgi_module modules/ to the httpd.conf.

4. Get a reasonably up to date version of django trunk (use svn and then copy to the machine).

5. Copy the django folder from this install into the C:\Python26\Lib\site-packages folder and add the bin folder therein to the system PATH.

6. Test the installation by starting python, calling import django and then django.VERSION

7. Configure Apache to use the mod_wsgi module as in the “How to use django with Apache and mod_wsgi” section of the django documentation.

8. Copy the HolyFamily files to C:\djangoisms and point the mod_wsgi setting at the django.wsgi file there.

9. Copy the media files across.

10. Make sure the admin media alias in httpd.conf points to the right place.

11. Change the django.wsgi file in HolyFamily to point to the correct places. Suddenly discover that the mysql backend for windows does not support python 2.6 and have to start all over again from scratch with 2.5.

Joy of joys!!!

As usual I spoke too soon, when I claimed that upgrading to use django-tagging was as easy as. There appears to be a problem with django-tagging if the model which a TagField is being attached to has a Primary Key which is text based. It has taken me a good 24 hours of head scratching to pin it down to this. This creates an error of the form:

invalid literal for int() with base 10: slug-name

when trying to save an object with a tag. Where slug-name refers to the slug of the object name. Basically to cure this requires removing the:


attribute from the model, flushing the database and re-syncing it with the model. This creates a new auto-incremented primary key field, which needs to be taken into account when reloading the data into the database. That’s all that is required (fingers crossed) to stop the error message from occurring.

Upgraded existing models to use the django-tagging application. Easy as!

Added a project planning section at to help me keep track of all projects here, at school for our sister site and personal.

Woohoo! I just installed lispbuilder-sdl in about 3 minutes. Fantastic, I just need to remember to do:

(require :cffi)
(require :lispbuilder-sdl)

Plus I guess any other lispbuilder-sdl parts which we want to use.

More later.

I’ve used my Emacs+SBCL installation to process the  Reports from into Student and Teacher user names and profiles for the Moodle installation, plus creating the Courses and assigning both students and teachers to the correct courses. The process involved just shy of 7000 records so I was very happy that everything went so swimmingly. It took roughly a morning to do, most of which was spent massaging the csv files to have exactly the correct formats.

As a sideline I was also able to process the SIMS data to produce class-lists for all of the Maths Sets so that they could be uploaded to MyMaths, which took a grand total of about 2 hours. The main stumbling block being that I had the output file for the script set up as :if-exists :append instead of :if-exists :supersede which meant that no matter how I altered the script to correct it, all I could see was the incorrect initial lines. If I’d noticed earlier, it would have taken me approximately 30 minutes to do all in. Typical.

Tried last night to get my head round CL-PPCRE, the Common Lisp Regex library derived from a PERL library with a similar name. Unfortunately, I just ended up going round in circles. I think I need to go back and look at Regexes in another language that I know, as the Common Lisp examples are somewhat sparse.

Yesterday I became increasingly frustrated trying to download and install a library to use with my SBCL installation, a socket library (usocket and another which I can’t remember) in fact. This started me on my quest to work out how packaging works in Common Lisp. Hence my previous posts on make-package and defpackage, although these seem more for my own projects. To install other peoples libraries, asdf-install (which seems to use asdf: another system definition facility) seems to be one way to go.

To install asdf first in SBCL, we need to add the following to our .sbclrc file (I had to create this on Debian Lenny in my home folder):

(require :asdf)

since asdf is incorporated in SBCL we don’t need to download or install anything else. We need to add a local folder to the list of possible sites to install libraries in, I created a .sbcl folder with a sub-folder called asdf-registry in it, then added:

(pushnew "/home/amos/.sbcl/asdf-registry/" asdf:*central-registry* :test #'equal)

to the .sbclrc file. However when I started using asdf-install it ignored this folder and created two new folders called site and systems respectively, and a file called trusted-uids.lisp.

I then added:

(require :asdf-install)

to my .sbclrc file, again as I’m using SBCL this is all that is needed. Restarting my lisp (I closed down emacs, restarted it, and restarted slime – there is probably an easier way to do this but I’m not sure what it is) made asdf and asdf-install be available.

To use asdf-install we can install a library by using one of:

(asdf-install:install :library-name)

(asdf-install:install "")

(asdf-install:install "/path/to/locally/downloaded/file")

This should result in a query as to whether we want to install the library system-wide or just for our user. As a system-wide installation requires root privileges the second option is likely to be the required one. Then it checks for a gpg key, giving the user the option to ignore it (I must work out how to check the key). Compilation/installation follows.

Once installed we can then use the library in the current lisp session. Once we’ve restarted our lisp we need to load but not install the library which on SBCL can be done with:

(require :library-name)

To install the regex library cl-ppcre we do:

(asdf-install:install :cl-ppcre)

perform a local install, ignore the gpg key and then we’re good to go. After restarting my lisp session all I have to do is:

(require :cl-ppcre)

to be able to access the library.

Most of this post is based on the ASDF-INSTALL tutorial found here.

Which gets me to the point I wanted to be at the other day. There is another ASDF-INSTALL Tutorial which gives details of how to create packages which I’ll look at another time. There are also some instructions in the one linked to above concerning an earlier system for packaging libraries, called mk:defsystem, which I’ll also need to have a look at.

Another way of defining packages is to use “defpackage”m this appears to include all of the previous make-package things, it allows for the definition of functions which need to be exported (the public interface of the package), which functions need to be imported and from where.

To define a package we do:

(defpackage dave)

There are various options we can supply to defpackage which the Hyperspec gives as:

option::= (:nicknames nickname*)* |
          (:documentation string) |
          (:use package-name*)* |
          (:shadow {symbol-name}*)* |
          (:shadowing-import-from package-name {symbol-name}*)* |
          (:import-from package-name {symbol-name}*)* |
          (:export {symbol-name}*)* |
          (:intern {symbol-name}*)* |
          (:size integer)

These allow us to do various things which make-package allows us to do separately.

The Hyperspec for packages is here.

A very basic example is:

(defpackage dave
    (:documentation "Dave's package"))

The other options work in a similar way.