The house sale closed yesterday, and I must say it is a lackluster boring finish to what was a great ride at the start. When we listed the house, by the end of the first week on the market, we had 6 offers, all above asking. We took 4 offers into a second round, and ended up selling the house for almost 8% above asking. After we accepted the offer, everything was dead easy. We had to do almost nothing until last week, when we signed the escrow papers in preparation for the close. As escrow closed yesterday, we are now in a rentback on this house, while we move. Since we have not found another house yet, there is no drama. I am sure that it will happen soon enough
Popularity: 9%
We have quite a large project at work, and when starting fresh ant was running out of memory. No documentation that I found, but I found the answer in the source (don’t you love open source
?). On windows, when you type ant, you are actually calling ant.bat, which tries to get its JVM arguments from a script called antrc_pre.bat in your home directory. So, it is a simple matter of creating the antrc_pre.bat and adding the following to it:
set ANT_OPTS=-Xmx1024m
Now, when I run Ant, the JVM is given up to 1 gigabyte, which should be enough
Popularity: 21%
More mod_python work, and I was seeing that session.is_new() was always returning true. Installed Live HTTP Headers into Firefox to debug, and looking at the Cookie being set, the path was mangled. Google led me to found out that you need to set the following in your config. This example is the balance to an
Alias /test
directive with:
PythonOption ApplicationPath /test
located in the <Directory> that the Alias is pointing to. This does not need to be done if the drectory is underneath the DocumentRoot. Simple, but it can trip you up when you can’t find the data you just stored in the session.
Popularity: 8%
In using mod_python, I finally installed it on a Windows XP box running Apache 2.0.48 and mod_python 3.1.2b (the latest binary I can get today). When I tried to do my basic authentication configuration and testing, I kept getting HTTP 500 errors, instead of the 401 that I was expecting. When I tried to print out the user and password in the log, I was getting both as None. So, off to Google, and back in 10 minutes with the answer: When doing HTTP Basic authentication with mod_python as the Authentication Handler on Apache 2 running on Windows XP, the mod_python module needs to be loaded before the authentication module.
Once I moved mod_python to the front of the LoadModule list in my httpd.conf, everything is working again. I am not sure if this is a mod_python bug, or an Apache bug. Anyone have any ideas?
Popularity: 9%
Since I have a new itch to build yet another web framework (am I not every engineer on the face of the planet?), and I am getting tired of the compilation cycle in Java during development, I have been checking out Python. I looked at several of the pyhton web frameworks, and some are very complicated, while some of them just try to be servlets, mod_python was the only one that I found that doesn’t do a lot of framework stuff (this is good, since I want to do that)
After digging deeper into mod_python, including installing it on multiple machines (RedHat, Debian, and Mac OS X), I have a few things to report:
- I am talking about mod_python 3.x, which only runs on Apache 2. If you want to use Apache 1.x, try mod_python 2.x, but YMMV. If you are not using Apache, stop reading this now, since mod_python is designed and built to expose the Apache API.
- You really should be using Python 2.3 or greater
- mod_python is currently a bit testy on Mac OS X. I did have the examples running, but have now lost them. Mac OS X support is still a work in progress. I hope to report more success on this front in the future.
- The version I am testing is 3.1.3
- If you want to program the webserver down at the API level, mod_python is perfect. As I am going to try and do a completly free web framework, this fits right into my plan. Working at the API level allows you to change a lot of things about processing web requests, which is actually pretty enlightening. You can read more about the Apache API.
- mod_python includes support for sessions and cookies, as well as a newly released processor for ‘Python Server Pages’. I will write more about these in the future
Overall, first impression is that it is clean and light, and this happens to be exactly what I am looking for. No introduction can be complete without some sort of microbenchmark
And considering that I want a fast web framework, I had better start the manic performance chants now
So, we start with the Hello World (obligatory):
mod_python Hello World
from mod_python import apache
def handler(req):
req.content_type = “text/plain”
req.write(”Hello World”)
return apache.OK
We drop this into a python file somewhere (test.py), and add the following to our apache configuration:
Apache configuration for mod_python Hello World
<Directory /usr/local/apache2/htdocs/pytest>
AddHandler mod_python .py
PythonHandler test
</Directory>
Now when I hit http://sarge/pytest/test.py, I see “Hello World”. Easy enough, but is it fast enough? Good question.
Running ApacheBench (ab), with the command ab -c 30 -n 10000 http://sarge/pytest/test.py, I get 1073 hits per second! I think that could be fast enough, but we should test something else to compare it. I chose static files, since Apache is pretty fast at that. I wrote a static file containing the text “Hello World”, and I get 2100 requests/sec. So I am giving up quite a bit of overhead. This does not deter me. Is it good enough? Absolutely. Let’s try PHP. Same test (echo Hello World), and we get 1061 requests per second. So, mod_python seems to have the same overhead as PHP (4.3.4).
Popularity: 11%
Since Alex and I are trying to be good netizens, and we want to spare the precious bandwidth, we implemented gzip support for most of our websites. Since we are using Apache and PHP with the great b2 rewrite that is WordPress, I want looking for documentation.
If you are using Apache 2.0, follow along, this is relatively painless. Reading the great documentation for Apache 2.0 mod_deflate, just add the recommended configuration to your httpd.conf and restart apache.
Add this to your httpd.conf
AddOutputFilterByType DEFLATE text/html text/plain text/xml
<Location />
# Insert filter
SetOutputFilter DEFLATE
# Netscape 4.x has some problems…
BrowserMatch ^Mozilla/4 gzip-only-text/html
# Netscape 4.06-4.08 have some more problems
BrowserMatch ^Mozilla/4\.0[678] no-gzip
# MSIE masquerades as Netscape, but it is fine
# BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
# NOTE: Due to a bug in mod_setenvif up to Apache 2.0.48
# the above regex won’t work. You can use the following
# workaround to get the desired effect:
BrowserMatch \bMSI[E] !no-gzip !gzip-only-text/html
# Don’t compress images
SetEnvIfNoCase Request_URI \
\.(?:gif|jpe?g|png)$ no-gzip dont-vary
# Make sure proxies don’t deliver the wrong content
Header append Vary User-Agent env=!dont-vary
</Location>
See how easy this is when someone else did most of the work?
Now we test it. Since Ted has done the legwork on this, all we need to do is ask Leknor if everything is good by navigating here to see if we are now gzipped.
Summary: It is not terribly hard to add gzip support to your blog entries (or your entire website), as long as you ask the web wizards for the magic incantations. YMMV.
Popularity: 10%
Since I am archiving all web access logs as gzipped files, we needed to read them using our custom php script. Well, the fine documentation on php.net tells you exactly how to do it, if only your php install had it enabled. What to do? Just add the directive to your configure script, and you are good to go:
./configure (all my directives) –with-zlib=/usr; make; make install; apachectl restart
Then, in your php, just replace something like this:
$fd = fopen($todaylog, “r”);
with:
$fd = gzopen($todaylog, “r”);
How hard do we have to make it in java land? I leave that 30+ lines of code as an excercise to the reader.
Popularity: 11%
find /usr/local/apache2/logs -type f | grep `date +%Y%m%d` | grep -v gz | xargs -n 1 gzip
Popularity: 9%
Upgraded to Tasks Pro 1.0rc1 (from beta 9). Clean upgrade, the way it should be. I am very pleased with the functionality that has come out of Alex in Tasks Pro, and I expect that this will be one of the must have server apps of any capable workgroup.
Popularity: 7%