Cannot Get Form To Work

Victor Subervi victorsubervi at
Thu Jul 23 11:46:16 EDT 2009

When the form comes up the first time, there is the default value for num.
When I fill in a number in the form and press send, even though the form
sends to itself (same page name), I would think it would read the number
sent. Here again is the code:

from primeNumbers import primeNumbers

 lang = form.getfirst('lang', 'en')
 browser = form.getfirst('browser', 'all')
 site = form.getfirst('site', 'bridge')
 num = form.getfirst('num','')

ourFile = string.split(__file__, "/")
p = ourFile[len(ourFile) - 1]
p = p[: - 9]
site = ourFile[4][:-10]
if site != '':
 site = site[:-1]

print "Content-Type: text/html"
print """
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "">
<head xmlns="">
if num != '':
 num = round(float(num))
 roots = primeNumbers(num)
 print roots
if num == '':
 print """
<form action="" method="post">
<input type="text" name="num" size="20" maxlength="20" value="Enter number
here..." onfocus="this.value=''" />
<input type="image" src="" name="search"
id="search" />
print '</body></html>\n'
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the Python-list mailing list