[mod_python] How to use Classes

Graham Dumpleton grahamd at dscpl.com.au
Sat Jul 15 18:18:09 EDT 2006


On 15/07/2006, at 11:55 PM, Sanjeev Divekar wrote:

> Hi guys
>
> How can i use Classes in mod_python.
> ********************************************************************** 
> ***
> class myclass:
>    def __init__():
>        return "Hello"
>
>    def index(req,para=''):
>        tmpl = psp.PSP(req, filename='a.html')
>        tmpl.run(vars={'para':para})
>        return
>
>    def show_data(req, para):
>        msg = "Your first name is " + para[0]
>        index(req, para=msg)
>        return

BTW, you are missing the 'self' parameter as first argument in your  
class
methods in the above. Forgot to fix that. If you don't understand,  
you may
want to review how to write classes in Python and work that out before
trying mod_python.

Graham


More information about the Mod_python mailing list