开发者

Python Mongo DB mod_wsgi form action insert

I have a web page generated by newreg.py, when i click on Save / submit button, action written in insertNew.py to read the data and insert into MongoDB.

In newreg.py

     html += '<form method=post action="insertNew.py">'

 state = form.getvalue('state','<font color="#FF0开发者_如何转开发000">ERROR</font>')
 district = form.getvalue('district','<font color="#FF0000">ERROR</font>')
     dcode = form.getvalue('Dcode','<font color="#FF0000">ERROR</font>')

' html += '

in insertNew.py

 connection = Connection('localhost', 27017)
 db = connection.health
 tc = db.tb_treat_card
     newPatient = str(state)     
     tc.insert()[newPatient]
     html += newPatient
     output = html
     mimeType = "text/html"

     status = "200 OK"
     response_headers = [("Content-type", mimeType),
        ("Content-length", str(len(output)))]

     start_response(status, response_headers)
     return [output]

The following is the error from apache log

[Tue Aug 30 14:12:20 2011] [error] [client 192.168.1.9] Traceback (most recent call last):
[Tue Aug 30 14:12:20 2011] [error] [client 192.168.1.9]   File "/home/dev/wsgi-scripts/newreg.py", line 178, in application 
[Tue Aug 30 14:12:20 2011] [error] [client 192.168.1.9]     return handler.do(environ, start_response)
[Tue Aug 30 14:12:20 2011] [error] [client 192.168.1.9]   File "/home/dev/wsgi-scripts/newreg.py", line 156, in do
[Tue Aug 30 14:12:20 2011] [error] [client 192.168.1.9]     html += str(newPatient)
[Tue Aug 30 14:12:20 2011] [error] [client 192.168.1.9] NameError: global name 'newPatient' is not defined
[Tue Aug 30 14:12:20 2011] [error] [client 192.168.1.9] File does not exist: /home/dev/wsgi-scripts/favicon.ico

and the screen does not show any error, just refreshes the web page. ALSO there is not insert happening in MongoDB.

please help !!!

Thanks


Perhaps try a full Apache restart. The error message doesn't match the code snippet you provided.

Process restarts are required after code changes because they will not be detected automatically. Read:

http://code.google.com/p/modwsgi/wiki/ReloadingSourceCode

Recommended you use daemon mode and touch WSGI script file after any changes being made to trigger a process restart.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜