IMServer:mod wsgi: Difference between revisions
From KitwarePublic
Jump to navigationJump to search
No edit summary |
No edit summary |
||
Line 19: | Line 19: | ||
* Script to test persistent connections. | * Script to test persistent connections. | ||
< | <pre lang="python"> | ||
sys.path.append("/var/www-dj/") | sys.path.append("/var/www-dj/") | ||
conn = pymongo.Connection() | conn = pymongo.Connection() | ||
db = conn["clay1"] | db = conn["clay1"] |
Revision as of 15:56, 19 January 2011
wsgi interface in Apache
- Recompile with the matching python version
- I had issues with python 2.4.* but worked well with python 2.6.*
When wsgi interface uses modules from the local directory, the script should first append python path as follows otherwise the script which runs without errors in debug mode will not be able to run when called from wsgi interface.
<source lang="python">
sys.path.append('/var/www-dj/') from mongo import m
</source>
Development
- Any wsgi script must be able to maintain persistent connection with mongo to boost speed
- Script to test persistent connections.
sys.path.append("/var/www-dj/")
conn = pymongo.Connection()
db = conn["clay1"]
try:
import test6
except:
class sm():
def __init__(self):
pass
self.x = 177;
test6 = sm()
def application(environ, start_response):
""" The WSGI test application """
# emit status / headers
status = "200 OK"
str1 = "New value of X is %d"%(test6.x)
response_headers = [('Content-type', 'text/plain'),
('Content-Length', str(len(str1)))]
start_response(status, response_headers)
test6.x = test6.x+1
return [str1]
</source>