Setting up tools 2
This is the 2nd part of Setting up tools on Windows — notes mostly for myself. (No, I don’t run Django with MSSQL under IronPython. Yet.)
In this installment I add more stuff to Eclipse, and set up my apps under FastCGI on Linux-based shared host (I use DreamHost).
Eclipse
This section was updated on 9/30/2006.
I already set it up with PyDev and Subclipse. Now I want to add HTML/CSS editing. And I want to do AJAX.
- Run Eclipse and go to Help → Software Updates → Find and Install….
- Select Search for new features to install and hit Next.
- Select "Callisto Discovery Site", click Finish, and wait.
- Select WST (it’s under "Callisto DiscoverySite" ⇒ "Web and J2EE Development"), click Select Required to make sure you selected all components (it will add GEF and some other components).
- Click Next, accept licenses, click Next, and Finish to install all components.
Eclipse Web Standard Tools take care of everything but their JavaScript support is not what I consider "good". I need to install one more plug in, which will help me with Dojo-based Ajax: JSEclipse. This plug-in used to be not free for commercial development. Now, when InterACT was bought by Adobe, it appears to be free. The latest version includes a product key and a user name (see readme.txt in the downloaded archive for instructions).
- Download it here: http://www.interaktonline.com/Products/Eclipse/JSEclipse/Try-Download/. Their site requires registration but so far I was not spammed from them.
- Unzip the archive in your Eclipse directory and start Eclipse.
Sometimes it requires to be manually enabled as described in this JSEclipse KB article.
Now I am set with my web site editors.
Server
These instructions should be good for any FastCGI-based hosting. I use DreamHost, which allows to run Django using FastCGI. They have Python 2.3 and Python 2.4 installed, but not a lot of packages. DreamHost’s Wiki has very good instructions on how to use Django on DreamHost. But I want more than that.
- First order of business is to make my own Python using Ian Bicking’s virtual-python.py using PEAK’s instructions. Don’t forget to use python2.4 to run it, otherwise you’ll end up with Python 2.3.
- Now I have an installation, which can be administered just like the system Python.
- Install all necessary packages using Python Eggs, or whatever method you like. They will be installed locally.
- Install flup — it allows more tweaking options than fcgi.py.
Now I have everything installed but how to run it?
- Run python (should be an alias to your local python2.4) and enter following lines:
- import sys
- print sys.path
- Save an output of print somewhere.
- Create django.fcgi (see below).
- Instead of YOUR_PATH include the saved output of print done in the previous step.
- Include correct settings module name.
- Make it executable using chmod 755 django.py.
#!/usr/bin/env python2.4
if __name__ == '__main__':
import sys, os
# your path goes here:
sys.path = YOUR_PATH
# your settings module goes here:
os.environ['DJANGO_SETTINGS_MODULE'] = 'your.settings'
from flup.server.fcgi import WSGIServer
from django.core.handlers.wsgi import WSGIHandler
server = WSGIServer(WSGIHandler(), maxThreads=50)
server.run()
This file will run the multithreaded version of flup. After consultations with the flup’s creator Allan Saddi I decided to restrict number of threads to 50 — the default was something like MAX_INT, which could overload a server in some cases. I tried to set some well knows FastCGI parameters as well but it looks like mod_fastcgi ignores them. Sigh.
Apache’s .htaccess file should be written according to the DreamHost’s Wiki article.
Now I have working Django on FastCGI under Apache, and I can add more Python packages to my system at will.