[Tutor] mod_python and other web frameworks

Intercodes intercodes at gmail.com
Thu Jan 26 15:03:34 CET 2006


 Christian,

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.



Intercodes

# simple example
> import cherrypy
> import time
>
> class MySection(object):
>     @cherrypy.expose
>     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
>
>     @cherrypy.expose
>     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()
>
> cherrypy.server.start()
> # 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!
>
> Christian
> http://www.dowski.com
>
> ps And "as a beginner", I would _not_ start with something like
> mod_python ;-)
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20060126/f9e2831c/attachment.htm 


More information about the Tutor mailing list