[wingide-users] Trying to debug a CGI script

Iain Simpson iainsimpson at ntlworld.com
Sat Sep 3 15:41:26 MDT 2011


I am starting to work my way through the 'Programming Python' Book (Mark 
Lutz 3rd Ed) and am having some problem with the web examples  (Chap 2 
step 6) so I decided to try the 'Advanced Debugging Topics).

I found I couldn't get Wing to halt at any of the breakpoints.

To simplify the situation I've added the wingdbstub.py code to the the 
small test program - cgi101.py (see attached listings)

I've added the logging feature in 'wingdbstub.py' and the output is 
shown on the browser print.

I've set 'Enable passive listen' and the debug status indicator is set 
to listen on  port '50005'.

The code is being obeyed - processing changes can be made and the 
logging is carried out- but Wing does not stop at the breakpoints.

It's probably something stupid but I can't see it.

Any ideas

Iain Simpson
-------------- next part --------------
1. html file
==========

<html>
<title>Interactive Page</title>
<body>
<form method=GET action="cgi-bin/cgi101.py">
    <P><B>Please Enter your name:</B>
    <P><input type=text name=user>
    <P><input type=submit>
</form>
</body></html>

2. cgi101.py
===========

note lines marked '*' have been added for test 

#!/usr/bin/python
import cgi
import wingdbstub
*stat='not started'

form = cgi.FieldStorage()                # parse form data
print "Content-type: text/html\n"        # hdr plus blank line
print "<title>Reply Page</title>"        # html reply page
if not form.has_key('user'):
    print "<h1>Who are you?</h1>"
*    stat='no user'
else:
    print "<h1>Hi There  <i>%s</i>!</h1>" % cgi.escape(form['user'].value)
*   stat=cgi.escape(form['user'].value)
       
* print "<h2>Status : <i>%s</i>!</h2>" % cgi.escape(stat)
    

3. Browser output

{logging from wingdbstub}
wingdbg - 2011/09/03 21:47:56 - 'USER EXCEPTION' wingdbg - 2011/09/03 21:47:56 - 'GeneratorExit:' 'None' wingdbg - 2011/09/03 21:47:56 - 'Traceback:' wingdbg - 2011/09/03 21:47:56 - ' File "/usr/lib/python2.7/cgi.py", line 590, in \n return any(item.name == key for item in self.list)' wingdbg - 2011/09/03 21:47:56 - '_BlockUntilReadyToRun: ' wingdbg - 2011/09/03 21:47:56 - ' filename = /usr/lib/python2.7/cgi.py, lineno = 590' wingdbg - 2011/09/03 21:47:56 - 'USER EXCEPTION IN BLOCKUNTILREADYTORUN' wingdbg - 2011/09/03 21:47:56 - 'SENDING PROGRAM STOPPED ON EXCEPTION' wingdbg - 2011/09/03 21:47:56 - 'NETSERVER PROGRAM STOPPED' wingdbg - 2011/09/03 21:47:56 - 'QUIT=FALSE' wingdbg - 2011/09/03 21:47:56 - 'THREADS=' [(26575008, u'MainThread', 0)] wingdbg - 2011/09/03 21:47:56 - 'CURRENT THREAD=' 26575008 wingdbg - 2011/09/03 21:47:56 - 'STACK =' [((u'/home/iain/workspace/python_text/PP3E-Examples-1.2/Examples/PP3E/Preview/cgi-bin/cgi101.py', 9, u"if not form.has_key('user'):\n", u'', []), 9), ((u'/usr/lib/python2.7/cgi.py', 590, u' return any(item.name == key for item in self.list)\n', u'has_key', [u'self', u'key']), 590), ((u'/usr/lib/python2.7/cgi.py', 590, u' return any(item.name == key for item in self.list)\n', u'', [u'.0', u'item']), 590)] wingdbg - 2011/09/03 21:47:56 - 'FRAMEIDX' 2 wingdbg - 2011/09/03 21:47:56 - 'CHECK FOR CONNECTION' wingdbg - 2011/09/03 21:47:56 - 'LISTENER INFO:' ('0.0.0.0', 50015) wingdbg - 2011/09/03 21:47:56 - 'SELECT RESULT' [] [] [] wingdbg - 2011/09/03 21:47:56 - 'CHECK FOR CONNECTION' wingdbg - 2011/09/03 21:47:56 - 'LISTENER INFO:' ('0.0.0.0', 50015) wingdbg - 2011/09/03 21:47:56 - 'SELECT RESULT' [] [] [] wingdbg - 2011/09/03 21:47:56 - 'CONTINUE' wingdbg - 2011/09/03 21:47:56 - 'EXITING TO RUN'

{output from cgi101.py}
Hi There irs2!
Status : irs2!


wingdbg - 2011/09/03 21:47:56 - '_CB_DebugThread called with thread_id =' 139987206219552 wingdbg - 2011/09/03 21:47:56 - '_CB_DebugThread returning' 1 wingdbg - 2011/09/03 21:47:56 - '_CB_DebugThread called with thread_id =' 139987206219552 wingdbg - 2011/09/03 21:47:56 - '_CB_DebugThread returning' 1 wingdbg - 2011/09/03 21:47:56 - 'ProgramQuit called' wingdbg - 2011/09/03 21:47:56 - 'STOPPING DEBUG' wingdbg - 2011/09/03 21:47:56 - 'RESET' wingdbg - 2011/09/03 21:47:56 - 'setting __fClient to' None wingdbg - 2011/09/03 21:47:56 - 'RESET' wingdbg - 2011/09/03 21:47:56 - 'netserver CLOSECHANNEL' wingdbg - 2011/09/03 21:47:56 - 'Closing attach listener socket' 


4 system 



More information about the wingide-users mailing list