[mod_python] Tips and Tricks initiative

vio vmilitaru at sympatico.ca
Wed Jul 3 15:32:39 EST 2002


Hello,
Inspired by Apache's excellent "URL Rewriting Guide" (http://httpd.apache.org/docs/misc/rewriteguide.html), I would like to suggest that the mod_python maintainers compile a similar document, focussed exclusively on short, practical tricks and tips documenting how mod_python can help to solve some typical problems. This would, to some extent, cut off on redundant posts to the list, as well as help spread knowledge from the more experienced to the more 'mod_python challenged' (like myself). There is no better selling argument for mod_python than a few well written lines of 'mod_python' code ...

An example of a possible entry to the 'mod_python Tips&Tricks' list:


Generic Redirect

Description:
  problem description blah blah ... In this example: basically simulating mod_rewrite in mod_python.

Solution:
  additional blah blah explaining how we are going to brilliantly solve that mind boggling problem in 2 lines of code ...

  def handler(REQUEST):
    # some code generating our url goes here

    url = 'http://www.yahoo.com' # an example url to test the redirect code
    REQUEST.headers_out["Location"] = url
    REQUEST.status = 302
    REQUEST.send_http_header()


For instance, I'd be very interested to read in such a tricks and tips list how to avoid the overhead of creating a database connection at each call to 'handler'. And so on.

Cheers, Vio



More information about the Mod_python mailing list