2011-08-30 4 views
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에서 삽입이 일어나지 않습니다.

도와주세요!

감사합니다.

+0

newPatient를 기록하고 정의되지 않은 이유를 확인하십시오. 아파치를 다시 시작해야 할 수도 있습니다. – Efazati

답변

0

아마도 전체 Apache를 다시 시작하십시오. 오류 메시지가 귀하가 제공 한 코드 스 니펫과 일치하지 않습니다.

자동으로 감지되지 않기 때문에 코드를 변경 한 후에 프로세스를 다시 시작해야합니다. 읽기 : 변경 사항은 프로세스를 다시 시작 트리거 만든 후 당신은 데몬 모드와 터치 WSGI 스크립트 파일을 사용하는 것이 좋습니다

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

.

관련 문제