[mod_python] Weird Publisher Problem, Configuration?

David abbottdavid at bellsouth.net
Sun Feb 8 21:53:11 EST 2009


Ron Phelps wrote:
> I am using a simple publisher example from 2005 that prompts the user to
> select a month of the year and I think it is to return a html page to
> the browser with a formatted month. However,  instead of returning the
> html Firefox prompts me to save the file or open with another
> application.  Do I need to add the Publisher handler in the apache2.conf
> file? 
>   
Here is mine;
# -*- coding: UTF-8 -*-
import calendar
from mod_python import apache

def index():   

   return """

<html><head>
<title>A simple "get month" script</title>
</head>
<body>
<form value="form" method="POST" action="getmonth.py/getMonth">
<p>
<hr>
<br />
Show which month for 2009 ?: <br />
<select name="month">
   <option value="1">January</option>
   <option value="2">February</option>
   <option value="3">March</option>
   <option value="4">April</option>
   <option value="5">May</option>
   <option value="6">June</option>
   <option value="7">July</option>
   <option value="8">August</option>
   <option value="9">September</option>
   <option value="10">October</option>
   <option value="11">November</option>
   <option value="12">December</option>
</select>
<br />
<input type="submit" value="Show Month" action="getmonth.py/getMonth">

</form>
</body>
</html>
"""
def getMonth(req,month):
    req.content_type = "text/html"
    req.write('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">')
    req.write('<html xmlns="http://www.w3.org/1999/xhtml" lang="en" 
xml:lang="en">')
    req.write('<head><title>Month</title></head>')
    req.write('<body>')
    req.write('<p>')
    req.write('<hr />')
    req.write('<br />')
    req.write('</p>')
    req.write('<pre>')
    req.write(calendar.month(2009, int(month),2,3))
    req.write('</pre>')
    req.write('</body>')
    req.write('</html>')
   
<Directory /var/www/localhost/htdocs/python>
    AddHandler mod_python .py
    PythonHandler mod_python.publisher
    PythonDebug On
</Directory>

Here it is;
http://dwabbott.com/python/getmonth.py

-david

   
 
 

-- 
Powered by Gentoo GNU/LINUX
http://www.linuxcrazy.com
pgp.mit.edu




More information about the Mod_python mailing list