0
newreg.py에 의해 생성 된 웹 페이지가 있는데, Save/Submit 버튼을 클릭하면 insertNew.py로 작성된 액션으로 데이터를 읽고 MongoDB에 삽입합니다. 에서는Python Mongo DB mod_wsgi 폼 액션 삽입
newreg.py
html += '<form method=post action="insertNew.py">'
state = form.getvalue('state','<font color="#FF0000">ERROR</font>')
district = form.getvalue('district','<font color="#FF0000">ERROR</font>')
dcode = form.getvalue('Dcode','<font color="#FF0000">ERROR</font>')
' HTML + ='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]
이하
아파치 로그에서 오류가
[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
이고 화면에 오류가 표시되지 않으면 웹 페이지를 새로 고칩니다. 또한 MongoDB에서 삽입이 일어나지 않습니다.
도와주세요!
감사합니다.
newPatient를 기록하고 정의되지 않은 이유를 확인하십시오. 아파치를 다시 시작해야 할 수도 있습니다. – Efazati