#!/usr/bin/python print "Content-type: text/html\n" print """
Up to 5 points can be chosen, and will be added to the database. Click below when done.
I'm done, show me results """ import os if os.environ.has_key('QUERY_STRING'): #not the first time called (without coords) coord = os.environ['QUERY_STRING'] import pg con=pg.connect("wireless") con.query("insert into locations values ('%s')"%coord) # presupposing one has created table locations in database wireless as follows: # create table locations (coord point); # grant select,insert on locations to apache; # point is a useful sql type, for example the following queries will find the points # within a radius of 50 of the comet's head: # select * from locations where coord <-> '230,150' <= 50; -- distance <= 50 # select * from locations where coord @ circle('230,150', 50); -- contained in object