The Artima Developer Community
Sponsored Link

Python Buzz Forum
On mod_python

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Simon Willison

Posts: 282
Nickname: simonw
Registered: Jun, 2003

Simon Willison is a web technology enthusiast studying for a Computer Science degree at Bath Uni, UK
On mod_python Posted: Aug 28, 2003 9:02 PM
Reply to this message Reply

This post originated from an RSS feed registered with Python Buzz by Simon Willison.
Original Post: On mod_python
Feed Title: Simon Willison: Python
Feed URL: http://simon.incutio.com/syndicate/python/rss1.0
Feed Description: Simon Willison's Python cateory
Latest Python Buzz Posts
Latest Python Buzz Posts by Simon Willison
Latest Posts From Simon Willison: Python

Advertisement

So, I'm getting stuck in to mod_python in a pretty big way at the moment. I've never even used mod_perl before, so coming from PHP this is turning out to be a real eye opener.

The key thing to realise about mod_python is that it gives you full control over the whole Apache request. Unlike PHP, you're not writing scripts that just happen to use Apache as a go between - mod_python exposes a pretty big chunk of Apache's internal API, and you are expected to hook straight in to it and start doing things. This certainly takes a while to get used to, but comes with some pretty big benefits. For one thing, your code is loaded once (well, once by each Apache process) and stays in memory. This means that global variables within your scripts persist between requests! Unfortunately, each Apache process (of which there are usually quite a few) has its own copy of the code so you can't use this persistence ability for things like sessions, but it's great for pooling database connections and keeping unchanging data such as templates in memory.

You can write your own handlers for the various parts of the Apache request. So far I've only been playing with the handler that serves up content, but it's possible to do things like create a handler for the "Authentication" phase that authenticates users in some special way.

My biggest worry at the moment concerns the relative lack of documentation for mod_python on the web - the manual is pretty good, but other than that there's precious little to get your teeth in to. Luckily the module has a reasonably high traffic mailing list which has so far answered all of the questions I've thrown at it promptly and in great detail. I hope to write more about mod_python as I become more comfortable with it. If anyone has any tips, I'd love to hear them.

Read: On mod_python

Topic: Random links Previous Topic   Next Topic Topic: Roundup demo has moved

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use