G
Golawala, Moiz M (GE Infrastructure)
Hi All,
I am very new to mod_python (I have developed application with python but am new to web development in general). I have read most of the documentation and I have a couple of questions. I am planning to use mod_python along with Cheetah to build an internal website for my company. So far I have include some basic handlers in apache and can view a hello world script on my browser. Now when I try to do something a little more complicated I am lost.
I have a couple of text fields that I want the user to fill out and then hit the submit button. I can get that html page up but I don't understand the mechanism where once a user hits the submit button, how does he/she get to the next page on the site.
In the documentation I don't see any multi page working examples. Can some one point me to some resource that has working mult-page html (PSP or Cheetah based) examples with the necessary Directory tags in the httpd.conf file so I can better understand what is going on.
Here is an some code to explain what I am trying to do and what my confusion is:
In my httpd.conf file:
<Directory /var/www/html/>
PythonHandler main
PythonDebug on
</Directory>
in my main.py file:
from cheetah.Template import Template
from mod_python import apache
def handler(req):
t = Template(file,"/var/www/html/main.tmpl")
textlen = len(str(t))
req.set_content(t)
req.set_content_length(textlen)
apache.OK
in my main.tmpl file:
<html>
<head></head>
<body>
<form action="valid.py">
<input type="text" size="20" name="input1">
<input type="text" size="20" name="input2">
<input type="submit" name="submit" value="submit">
</form
</body>
</html>
My problem is that the browser renders the page that is defined in the main.tmpl file. But once I enter the text and click submit. I want the browser to display the page that is defined the template used in valid.py (as the form tag shows) but some how I get the main.py page back. The reason this is happening is that once I click the submit button, I get back to the server and the handler is invoked and main.py is called. I can never go to another page.
I am sure I am doing something wrong. Please can someone help me out.. Or direct me to some place that show an example of how this mechanism works correctly.
Again, any help is appreciated.
Thanks
Moiz Golawala
Moiz Golawala
GE Infrastructure, Security
Software Engineer
Enterprise Solutions
T 561 994 5972
F 561 994 6572
E (e-mail address removed)
www.gesecurity.com
791 Park of Commerce Blvd., Suite 100
Boca Raton, FL, 33487, U.S.A.
GE Security, Inc.
I am very new to mod_python (I have developed application with python but am new to web development in general). I have read most of the documentation and I have a couple of questions. I am planning to use mod_python along with Cheetah to build an internal website for my company. So far I have include some basic handlers in apache and can view a hello world script on my browser. Now when I try to do something a little more complicated I am lost.
I have a couple of text fields that I want the user to fill out and then hit the submit button. I can get that html page up but I don't understand the mechanism where once a user hits the submit button, how does he/she get to the next page on the site.
In the documentation I don't see any multi page working examples. Can some one point me to some resource that has working mult-page html (PSP or Cheetah based) examples with the necessary Directory tags in the httpd.conf file so I can better understand what is going on.
Here is an some code to explain what I am trying to do and what my confusion is:
In my httpd.conf file:
<Directory /var/www/html/>
PythonHandler main
PythonDebug on
</Directory>
in my main.py file:
from cheetah.Template import Template
from mod_python import apache
def handler(req):
t = Template(file,"/var/www/html/main.tmpl")
textlen = len(str(t))
req.set_content(t)
req.set_content_length(textlen)
apache.OK
in my main.tmpl file:
<html>
<head></head>
<body>
<form action="valid.py">
<input type="text" size="20" name="input1">
<input type="text" size="20" name="input2">
<input type="submit" name="submit" value="submit">
</form
</body>
</html>
My problem is that the browser renders the page that is defined in the main.tmpl file. But once I enter the text and click submit. I want the browser to display the page that is defined the template used in valid.py (as the form tag shows) but some how I get the main.py page back. The reason this is happening is that once I click the submit button, I get back to the server and the handler is invoked and main.py is called. I can never go to another page.
I am sure I am doing something wrong. Please can someone help me out.. Or direct me to some place that show an example of how this mechanism works correctly.
Again, any help is appreciated.
Thanks
Moiz Golawala
Moiz Golawala
GE Infrastructure, Security
Software Engineer
Enterprise Solutions
T 561 994 5972
F 561 994 6572
E (e-mail address removed)
www.gesecurity.com
791 Park of Commerce Blvd., Suite 100
Boca Raton, FL, 33487, U.S.A.
GE Security, Inc.