[mod_python] some questions about using mod_python

vegetax vegeta.z at gmail.com
Sat Mar 19 23:52:39 EST 2005


hi, i just finished reading the docs and i have some obstacles to start
implementing a web system using mod_python.

First 2 observations in the docs:
-please correct the docs in the hello world example,it doesnt work!
req.content_type = '/text/html' is needed,i spended an hour trying to find
the problem in the hello world??

-Please remark that in order to send any kind of output headers,including
cookies and sessions,the code should be before any req.write().

My doubts:

- PythonPath directive doesnt work at all,when i set it at any config level
i get a NOT FOUND error,from apache when i try to access anything that uses
mod_python, the definition is : PythonPath "sys.path + ['/devel/classes']"

- Where do i set a database connection pool to load at server
initialization ,so that all request can access it? is the pythonImport
directive the best place? where do i set a clean up function for the pool
at server finalization ?

- Is it ok to configure apache to just use one process and several threads
like in windows? what other implications it has? besides losing some of the
stability and safety that apache provides, is just that too many things go
wrong in the dynamic applications when mixing using both process and
threads.

- I want to use a MVC approach,the publisher's methods are the controlers
that do the processing and send internal redirects to psps to show the
results,so i need to pass objects to the psps from the pub methods,i need
those objects to be in the request object of the handler and available to
the target psp.

this code doesnt work,it shows an error saying req object has no
attribute,data: 

def regHandler(req):
    data = [1,2,'a']
    req.data = data
    req.internal_redirect('/var/www/myapp/psp/showReg.psp') 
    return apache.OK

showReq.psp:

the data :
<%= req.prev.data %>


I also tried to load the data in a session object retrieved or created in
reqHandler,but same results,the session object in the psp always creates a
new session and the gives : Key error, session object has no key 'data'

Also, the post in site
(http://dotnot.org/blog/archives/2004/06/27/nasty-deadlock-in-modpython-when-using-sessions/)
,describing that some rare things happens to session locks,when internal
redirecting between python handlers,in my case the pspHandler and the
pythonHandler or publisher? how can i overcome those issues?

What exactly happens between internal redirects that affect mod_python
behavior,sessions,etc, when used like i want to use it? And is it fast to
internal redirect a lot? since all request phases are processed every time.

Thanks, in advance, sorry to have to many doubts =P



More information about the Mod_python mailing list