[Tutor] mod_python and other web frameworks
intercodes at gmail.com
Thu Jan 26 15:03:34 CET 2006
You are certainly right. I couldn't get anything apart from "Hello world"
coding in mod_python. The mod_python manual is also bit vague, not for
beginners. I wonder why there aren't any good tutorials on mod_python.
I am having a look at quixote as a developer in this list suggested. I would
take a look at cherrypy if quixote is too deep for me.
Thanks for your time and the example. I believe your website is written
completely in cherrypy. Working on so many projects ,nice work.
# simple example
> import cherrypy
> import time
> class MySection(object):
> def index(self):
> yield "<h1>Hello, world!</h1>"
> yield "<a href='time'>Check the time</a>"
> # if you are using Python 2.3, you do the following to expose a method
> # index.exposed = True
> def time(self):
> return "<p>The current time is %s</p>" % self.get_time()
> # this method is not exposed and thus not accessible from the web
> def get_time(self):
> return time.ctime()
> # mount the class at the server root
> cherrypy.root = MySection()
> # end of example
> You can then run that script and visit http://localhost:8080/. That
> will call the "index" method of the MySection object mounted at the
> server root. You can also visit http://localhost:8080/time. However,
> http://localhost:8080/get_time is _not_ available to the web, because it
> is not "exposed".
> Anyhow, CherryPy is very pythonic and flexible. Use whatever DB you
> want (or flat files or ...). Use whatever templating language you want
> (or just return html from your methods.
> Anyhow, that's probably more info than you wanted. Good luck!
> ps And "as a beginner", I would _not_ start with something like
> mod_python ;-)
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Tutor