[mod_python] How declared correctly the way in the pg.html to the apache server can resolv the script python correctly

EdgardCosta edgardalvescosta at gmail.com
Tue Nov 20 21:25:16 EST 2007


Graham

95% of my problems wiht the form are resolved. The tutorial that you
post show a diferent way of write.

The mod_python see each function declared in a file like a new page.

So, the same happens with the form and your response.

In my case i post in each textfield values that are numbers. I want do
this: textfield1+textfield2.

The function don't understand intenger. Only string.

My results is like this: textfield1textfiel2. Exemple. 2+2=4 ; 22

How could i declared the variables correctly;

The code:

#!/pyhton/python
#formulario editado com kompozer
#autor: Edgard Costa

import cgi

def form1():
        b="""\

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
  <meta content="text/html; charset=ISO-8859-1"
http-equiv="content-type">
  <title>form.py</title>
</head>
<body>
<!-- method can be get or post -->
<div style="text-align: center;"><br>
Formularios Teste<br>
<br>
<form method="post" action="./show" name="form1">
  <div style="text-align: center;"></div>
  <table style="text-align: left; margin-left: auto; margin-right: auto;
height: 31px; width: 599px;" border="0" cellpadding="2" cellspacing="2">
    <tbody>
      <tr>
        <td style="text-align: center; width: 150px;"
valign="undefined">soma1</td>
        <td style="text-align: left; width: 227px;"
valign="undefined"><input name="soma1"></td>
      </tr>
      <tr>
        <td style="text-align: center; width: 150px;"
valign="undefined">soma2</td>
        <td style="text-align: left; width: 227px;"
valign="undefined"><input name="soma2"></td>
      </tr>
      <tr>
        <td style="text-align: center; width: 150px;"
valign="undefined"></td>
        <td style="text-align: left; width: 227px;"
valign="undefined"><button name="Soma"></button></td>
        <td align="center" valign="undefined"></td>
      </tr>
    </tbody>
  </table>
  <br>
</form>
<br>
mod_python<br>
<br>
<br>
<br>
</div>
</body>
</html>

        """
        return b

def show(req):
        soma1=req.form.getfirst('soma1','')
        soma2=req.form.getfirst('soma2','')
        c=soma1+soma2
        c=cgi.escape(c)

        r="""\
        <html>a soma eh:%s</html>
        """
        return r % c

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mm_cfg_has_not_been_edited_to_set_host_domains/pipermail/mod_python/attachments/20071121/7dbffe6e/attachment.html


More information about the Mod_python mailing list