Gregory (Grisha) Trubetskoy
grisha at modpython.org
Wed Aug 27 22:51:46 EST 2003
Call me stupid, but I don't get it :-) What's the point of the else clause if it's never reached? Grisha On Wed, 27 Aug 2003, Russell Nelson wrote: > The astute observer will notice the constant "if 1" whose unreachable > clause calls page(). That code returns an HTML document given the > pathname that the user handed in. Note that you'll never get the null > string, but instead 'index.html' or as configured elsewhere. > > #!/usr/bin/env python > > from mod_python import apache > import sys, os, re, string > > homedir = "/var/www/ae.russnelson.com/" > > def handler(req): > if 1: > req.content_type = "text/plain" > req.send_http_header() > req.write("Hello World!\n") > req.write('uri:'+req.uri+'\n') > req.write('filename:'+req.filename+'\n') > req.write('path_info:'+req.path_info+'\n') > if req.args: req.write('args:'+req.args+'\n') > else: > req.content_type = "text/html" > req.send_http_header() > req.write(page(req.filename[len(homedir):])) > return apache.OK > |