Sunday
27
Jun 2004

Nasty deadlock in mod_python when using sessions

(12:32 am) Tags: [Software]

I was using sessions in my mod_python application, and in certain cases it was just deadlocking the handler, and eventually choking the server to death. The fix was simple, finding it was hard :) My problem was in my authentication handler, I was doing a req.internal_redirect(), and that would hit the server before the handler returned. Since the original handler still had the session locked, I was losing 2 handlers per request!!! The fix was easy, just call session.unlock() just before the internal_redirect(). Works like a charm now!

Note that this only needs to be done in mod_python 3.1 and higher when you are doing an internal redirect. If the handler finishes normally, the session is automatically unlocked.

Popularity: 9%

Comments: (0)

Install mysql-python 1.0.0 on Mac OS X 10.3.4

(12:31 am) Tags: [Software, How do I...]

Step 1. Download mysql-python 1.0.0 from sourceforge and expand.
Step 2. Modify the setup.py script to remove library dirs that don’t exist and to change ‘crypt’ to ‘crypto’. Follow the directions in the readme otherwise.
Step 3. Profit! :)

Popularity: 19%

Comments: (0)

Compile your very own Emacs on OS X 10.3.4

(12:29 am) Tags: [Software, How do I...]

Once you have XCode 1.2 installed, just do the following:
Get the Emacs source from CVS:

cvs -z3 -d:ext:anoncvs@savannah.gnu.org:/cvsroot/emacs co emacs

Note that you must have the environment variable CVS_RSH=ssh.

cd emacs
./configure –with-carbon –without-x
make bootstrap
sudo make install

then copy the mac/Emacs.app to /Applications
Happy Emacs!!!

Popularity: 12%

Comments: (0)

Compile nearly anything on OS X 10.3.4 without errors

(12:27 am) Tags: [Software, How do I...]

Let’s say that you have just freshly installed OS X, and you are trying to build something, like Subversion, for instance. On the command line, you get an error something like:

checking for C compiler default output… configure: error: C compiler cannot create executables

I kept getting an error about the C compiler cannot create executables whenever I tried to compile Apache, or Emacs, etc. Apparently netiher XCode 1.0, or the 1.1 update is not enough. Installing the full XCode 1.2 solved this problem. Hope this helps someone using fink and wondering WTF!

Popularity: 12%

Comments: (0)

Install fink on OS x 10.3.4

(12:24 am) Tags: [Software, How do I...]

This one is the easiest, if you follow the steps in order. Also make sure that you have XCode 1.2 installed as a prereq.
1. Download the fink dmg (I got 0.70)
2. Install it
3. At the command line, run a ‘fink selfupdate’, and then a ‘fink update-all’.
You are now ready to start finking :)

Popularity: 12%

Comments: (0)

Compile mod_python on Mac OS XHOWTO Compile mod_python on Mac OS X

(12:19 am) Tags: [Software, How do I...]

I just got mod_python 3.1.3 up and running on Apache 2.0.49 on Mac OS X 10.3.4. Caveats: this is my own custom built from the source Apache, and you will need Fink installed with python 2.3 installed. If fink is already installed, just do a fink install python-23. Now the last step before we get started: if you open a terminal window, and type ‘python’, do you get python 2.3.3 (fink’s), or 2.3 (apple’s)? It is imperative that you end up opening the fink version of python (for dynamic loading reasons I won’t get into here). If you are not getting the fink version, try something like:

sudo ln -s /sw/bin/python2.3 /sw/bin/python
I compiled my apache with:

./configure –enable-so –with-mpm=worker
make
sudo make install (installs to /usr/local/apache2)

Then I compile and install mod_python:

./configure \
–with-apxs2=/usr/local/apache2/bin/apxs \
–with-python=/sw/bin/python2.3
make
sudo make install

Now, edit the httpd.conf to add the following line (mod_python does NOT do it for you)”

LoadModule python_module modules/mod_python.so

Now, start or restart apache:

/usr/local/apache2/bin/apachectl start (or restart)

Note that I used the full path here as Mac OS X ships with an apachectl in /usr/sbin.

That should be it. Follow the examples in the documentation at modpython.org and you should have a successful mod_python install.

Gotchas I encountered mainly have to do with file permissions mainly. If the nobody user cannot see the files you want to use, then they will not be served. I moved all of my development out of my home directory, since I did not want to mess with perms on my home directory and possibly invalidate my use of FileVault.

Happy Pythoning!!!

Popularity: 22%

Comments: (7)