[mod_python] Need Help ...Please!!!

Sean Davis sdavis2 at mail.nih.gov
Thu Mar 29 07:20:57 EST 2007


On Thursday 29 March 2007 07:54, nitin chandra wrote:
> Hi Everyone!
>
> I need some help here.
>
> I have a WinXP laptop, installed with Python2.4, Apache 2.0.59,
> mod_python-3.2.8.win32-py2.4.exe,
> psycopg2-2.0.5.1.win32-py2.4-pg8.2.0-release.exe, PostgreSQL 8.2.
>
> Now i have created a DB as "nitin" and a user "nitin", further i
> created 13 more tables within the DB. One of the
> tables is named as "area". This, "area", table has 11 fields. Two
> fields are left blank as they will
> be entered through a web interface.
>
> So i am trying to read the complete row and display the existing data
> in the table. The display of the data is to be done in various forms
> fields over the Web-interface / html(or CSS). Lastly, Enter data in
> blank form fields and update the table.
>
>
> I am writing a 'area.py' script for the above.
>
> ======================
>
> from mod_python import apache
> import sys, psycopg
>
> conn = psycopg.connect("dbname=nitin user=nitin passwd=" "")
>
> curs = conn.cursor()
>
>
>
> <head><title>Owners' Details Entered</title></head>
> <body bgcolor="#87CEFA">
> <table align=center border=2 cellpadding=6>
>
>
> curs.execute("SELECT * FROM area")
> rows = curs.fetchall()
>
> print <tr><td>rows</td></tr>
>
>
> </table>
> </body>
> </head>
>
> ===================
>
> And it does not work. When I load the page in IE, HTML works but the
> rest of the code is displayed as it is,i.e. as text.
>
> Are there any samples available on the net where i can look at.

You will probably need to read some documentation:

http://www.modpython.org/

I think you will probably need to follow the examples in the manual pretty 
closely.  Also, I would suggest that you do some reading on how the web 
works.  Knowing what HTML is, how dynamic webservers generate and deliver 
content, and how databases get involved are pretty important concepts to 
understand.

Sean


More information about the Mod_python mailing list