[mod_python] Getting request object

Daniel J. Popowich dpopowich at comcast.net
Wed Dec 7 15:04:30 EST 2005


Radek Bartoň writes:
> Hello.
> I like using mod_python's mod_python.publisher like this:
> 
> class MyClass:
>   def __init__(self):
>     # can I get request object here?
>     ...
>   def __str__(self):
>     ...
>   def method1(self, req):
>     ...
>   def method2(self, req):
>     ...
> 
> # or can I get request object here and pass it to MyClass's constructor?
> index = MyClass():
> ...
> 
> instead of classic usage:
> 
> ....
> def index(req)
>    instance = MyClass()
>    ....
> 

You may want to check out mod_python servlets which offers an object
oriented paradigm for web application development.  Each request is
represented by an instance of a class and the response is generated by
calling a series of methods on the class.  Check out the link below in
my signature.  There's a live tutorial you can try out.

Daniel Popowich
---------------
http://home.comcast.net/~d.popowich/mpservlets/



More information about the Mod_python mailing list