[mod_python] Re: pso and mod_python

thanos at 0x01.com thanos at 0x01.com
Wed Feb 12 18:28:45 EST 2003


yes I forgot to mention the following: 

mod_python by default looks for a method in your module called "handler"
so given this line in your .htaccess:
PythonHandler test 

your should add
> class TestHandler(TemplateHandler):
>     DEFAULT_TEMPLATE='cat_border'
handler = TestHandler().handle 

On the other hand with mod_python you can stipulate which handler to use:
PythonHandler test:TestHandler.handle 

But your handler class muts take a request object as an argument to the 
constructor. pso's TemplateHandler does not have a CTOR defined (Opps)
so you will have to add your own:
class TestHandler(TemplateHandler):
   def __init__(self, req):
        TemplateHandler.__init__(self) 

I hope this helps 

thanos 

 

 

 


Jeffrey Clement writes: 

> Thank you for your help.  I think I'm still missing something.  What is
> test.py? 
> 
> If I wanted: 
> 
> from pso.service import ServiceHandler
> from pso.handlers import TemplateHandler
> from dbsession import CookieDBImpl 
> 
> class TestHandler(TemplateHandler):
>     DEFAULT_TEMPLATE='cat_border' 
> 
> if __name__=='__main__':
>     ServiceHandler().run(TestHandler().handle, CookieDBImpl) 
> 
> How do I make this get run by mod_python.  It needs a handle method
> right?  And that takes a requestInfo parameter.  I assume the
> pso.modpython::fixup adds the pso() method to the request handler but
> how do I use this with my templateHandler? 
> 
> Thank you for all your help.  I'm finding PSO to be awesome for thhe
> current project I'm working on only just getting hung up once in a
> while. 
> 
> Jeff 
> 
> 
> On Tue, Feb 11, 2003 at 05:41:16PM -0500, thanos at 0x01.com wrote:
>> Jeffrey,  
>> 
>> You are right: the problem lies with your .htaccess file. It should be:  
>> 
>>  
>> 
>> 
>> AddHandler python-program .py
>> PythonHandler test
>> PythonFixupHandler pso.modpython::fixup
>> PythonLogHandler pso.modpython::cleanup  
>> 
>> You have to set the PythonFixupHandler and PythonLogHandler so pso can set 
>> thing up such as the session handling.  
>> 
>> A look through the pso guide 
>> [http://sourceforge.net/docman/display_doc.php?docid=11314&group_id=49265] 
>> shows me that this information is missing. It is
>> metioned in the "Easy mod_python Session Handling with pso.session" how-to
>> [http://www.scriptfoundry.com/modules/pso/doc/session-modpython.html] so I 
>> guess I am not completly guilty!  
>> 
>> Also trying out the sample mod_python code in the guide, i find things are 
>> broken. So I will post two bug reports to fix these problems.  
>> 
>> 
>> thanos  
>> 
>>  
>> 
>>  
>> 
>> 
>> Jeffrey Clement writes:  
>> 
>> >Hi there, 
>> >
>> >I'm trying to use PSO with mod_python and having some difficulties that
>> >I hope you can assist me with. 
>> >
>> >I have my appliaction: (test.py)
>> >=====================================================================
>> >from pso.service import ServiceHandler
>> >from pso.handlers import TemplateHandler
>> >from dbsession import CookieDBImpl 
>> >
>> >class TestHandler(TemplateHandler):
>> >    DEFAULT_TEMPLATE='cat_border' 
>> >
>> >if __name__ == '__main__':
>> >    ServiceHandler().run(TestHandler().handle, CookieDBImpl)
>> >===================================================================== 
>> >
>> >This above script runs fine as a CGI script.  However I have no idea how
>> >to make it run as a mod_python script. 
>> >
>> >I've got modpython installed and tested (I know it's OK) but It won't
>> >run my scripts.  I suspect the problem is I'm not understanding what
>> >exactly goes in .htaccess 
>> >
>> >I currently have:
>> >  AddHandler python-program .py
>> >  PythonHandler test.py
>> >  PythonDebug On 
>> >
>> >I know mod_python looks for a method handle.  Is there a mod_python
>> >wrapper that does I'm supposed to set as my PythonHandler?
>> >Thank you, Jeff 
>> > 
>> 
>>  
>> 
>> >-- 
>> >Jeff Clement 

>>  
>> 
>> 



More information about the Mod_python mailing list