BlogMatrix
 

Wednesday Morning Notes

edit David P. Janes 2006-08-30 11:57 UTC add comment  ·  ·  ·  ·  ·

There's a few more updates this morning:

  • We've added a "Text Gadget", so you can add your own arbitrary text to the sidebar. If you go to your admin page and then to your Profile, you will get instructions use this.
  • You can now control your comments (from your Profile). Your options are:
    • accept all comments, display immediately
    • accept all comments, but they must be approved before posting
    • don't accept comments
  • On a technical note, we've upgraded to mod_python 3.2.10 and we're using FileSession to manage sessions (which should cut a few tenths of seconds of page loading time).

Internals: bash 3.1 chokes mod_python 3.2.8

edit David P. Janes 2006-08-25 20:05 UTC add comment  ·  ·

I was rebuilding the BlogMatrix Platform on a Fedora Core 5 box this morning when I noticed mod_python wasn't being properly set up. The issue turns out to be that mod_python fails to build:

./configure: line 3427: syntax error near unexpected token `('
./configure: line 3427: `  as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null`'
+ exit 1

Through the magic of Google, we quickly found a fix:

A bug in bash 3.1 causes configure to fail. This has been reported on recent versions of Gentoo and and discussed on the mod_python mailing list:
http://bugs.gentoo.org/show_bug.cgi?id=118948
http://www.modpython.org/pipermail/mod_python/2006-January/019965.html
http://www.modpython.org/pipermail/mod_python/2006-January/019969.html

According to the gentoo bug report, the problem in configure.in is the double backslash escape sequence in the line:
MP_VERSION=`echo $MP_VERSION | sed s/\\"//g`

Changing this to:
MP_VERSION=`echo $MP_VERSION | sed s/\"//g`
fixes it for bash 3.1.

I wonder why mod_python is using \\" since the gentoo fix seems to work ok with bash 3.0 (and GNU sed) just as well. Is it there to support other shells, other sed versions, older bash versions... ??

I suggest mod_python adopts the gentoo fix, or avoids the problem altogether by using tr. eg.

MP_VERSION=`echo $MP_VERSION | tr -d '"'` 

Internals: tracking all actions against a page view

edit David P. Janes 2006-08-02 12:40 UTC add comment  ·  ·  ·

One of the nice things -- that took me a while to realize -- is that you're working in a single treaded environment in mod_python. One that's getting reused over and over and over, but while you got it you got it.

I've added an extension to bm_log to allow tracking of all logging related to creating a page. You use it as follows:

  • call Log.PageStart
  • do stuff
  • call Log.PageEnd

In fact, you don't even need to do this, since PageStart and PageEnd are always called in bm_page in the right places, so all you're responsible for is the "do stuff" part.

Now what does this do? Simple:

  • PageStart assigns a unique (random) id the logging function and records the start time
  • all subsequent calls to Log print the random id and the delta from the start time
  • PageEnd clears the unique id
 

Internals: Apache rewrite rules for Python attachments

edit David P. Janes 2006-07-18 10:55 UTC add comment  ·  ·

We were having a problem with serving .py files as attachments this morning. It turns out the problem was in the primary rewrite rules so I've made this rule:

RewriteRule   ^([^.]+)\.[^/]+/+(\d\d\d\d/\d\d\.\d\d/\d\d\d\d+/+.*)  http://semantic.blogmatrix.com/users/$1/podcasts/$2  

The first in it's group, that is, we'll attempt to serve attachments (recognized by all the \ds) before we look for .py files (in which URIs are normally passed straight through for mod_python handling by the secondary Apache).