fixed debugger, thanks Mariano and Paolo

This commit is contained in:
mdipierro
2012-12-26 11:55:05 -06:00
parent 4ddb7dea28
commit c8d4e03ead
4 changed files with 321 additions and 346 deletions
+1 -1
View File
@@ -1 +1 @@
Version 2.4.1-alpha.2+timestamp.2012.12.26.11.43.58 Version 2.4.1-alpha.2+timestamp.2012.12.26.11.54.07
@@ -180,9 +180,16 @@ function doToggleBreakpoint(filename, url) {
if (json.error) { if (json.error) {
window.location.href=json.redirect; window.location.href=json.redirect;
} else { } else {
if (json.ok==true && window.mirror) {
// mark the breakpoint if ok=True // mark the breakpoint if ok=True
editor.setMarker(json.lineno-1,
"<span style='color: red'>●</span> %N%")
} else if (json.ok==false && window.mirror) {
// remove mark if ok=False // remove mark if ok=False
editor.setMarker(json.lineno-1, "%N%")
} else {
// do nothing if ok = null // do nothing if ok = null
}
// alert(json.ok + json.lineno); // alert(json.ok + json.lineno);
} }
} catch(e) { on_error(); } } catch(e) { on_error(); }
+100 -77
View File
@@ -1,80 +1,93 @@
{{extend 'layout.html'}} {{extend 'layout.html'}}
{{block sectionclass}}debug{{end}} {{block sectionclass}}debug{{end}}
{{
<style> frm_trs = form.elements('tr')
table.sortable { tbl_rows = []
border-spacing:0px; for frm_tr in frm_trs:
} if frm_tr['_id'] != 'submit_record__row':
table.sortable td, table.sortable th { fld_label = frm_tr.element('td.w2p_fl')
padding: 2px 5px 2px 5px; fld_widget = frm_tr.element('td.w2p_fw')[0]
} fld_comment = frm_tr.element('td.w2p_fc')[0]
table.sortable thead { lbls = fld_label.elements('label')
background-color:#eee; lbl = ''
color:#666666; if len(lbls) > 0:
font-weight: bold; lbl = fld_label.elements('label')[0]
cursor: default; lbl['_class'] = 'control-label'
} pass
tr.error_ticket:hover { if fld_widget['_type'] == 'checkbox':
background-color: #eee; fld_widget = LABEL(fld_widget, _class='checkbox')
} else:
</style> fld_widget = CAT(fld_widget, SPAN('', _class='help-inline'))
pass
<script language="JavaScript"> if isinstance(fld_widget, SPAN):
function check(){ fld_widget['_role'] = 'asinput'
for (var i = 0; i < document.myform.elements.length; i++) { pass
var e = document.myform.elements[i]; tbl_row = DIV(lbl, DIV(fld_widget,
if (e.type == 'checkbox') e.checked = true; TAG['SMALL'](fld_comment,
} _class='help-block'),
} _class='controls'), _class='control-group')
function uncheck(){ tbl_rows.append(tbl_row)
for (var i = 0; i < document.myform.elements.length; i++) { else:
var e = document.myform.elements[i]; smt_btn = frm_tr.element('td.w2p_fw')
if (e.type == 'checkbox') e.checked = false; btn = smt_btn.elements('input')[0]
} btn['_class'] = 'btn btn-primary'
} tbl_rows.append(DIV(btn, _class='controls'))
jQuery(document).ready(function() { jQuery('.sourcecode').hide(); }); pass
</script> pass
form.element('table', replace=CAT(*tbl_rows))
<div class="applist f60"> form['_class'] = 'form-horizontal well well-small'
import re
if form.errors:
for key, value in form.errors.iteritems():
inpt = form.element(_name=key)
inpt_wrapper = inpt.parent
if inpt_wrapper['_class'] == None or \
not "controls" in inpt_wrapper['_class']:
inpt_wrapper = inpt_wrapper.parent
pass
inpt_wrapper.parent['_class'] += ' error'
inpt_wrapper.element(_class=re.compile('help-inline'),
replace=lambda me:SPAN(value, _class=me['_class']))
pass
form.errors.clear()
pass
}}
<!-- begin "debug" block -->
<div class="row-fluid">
<div class="applist f60 span7" style="padding-bottom:20px;">
<div class="applist_inner"> <div class="applist_inner">
<h2>{{=T("Breakpoints")}}</h2> <h2>{{=T("Breakpoints")}}</h2>
<div class="errorform"> <div class="errorform">
<form name="myform" method="post"> <form name="myform" method="post">
<input name="CheckAll" value="{{=T('check all')}}" <div class="tablebar">
onclick="check()" type="button"> <input value="{{=T('delete all checked')}}" type="submit" class="btn"/>
<input name="CheckAll" value="{{=T('uncheck all')}}" </div>
onclick="uncheck()" type="button"> <div class="row-fluid">
<input value="{{=T('delete all checked')}}" type="submit"><br><br> <div class="span12 errors">
<table id="trck_breakpoints" class="sortable table table-hover table-condensed">
<table id="trck_breakpoints" class="sortable">
<thead> <thead>
<tr> <tr>
<th>{{=T("Delete")}}</th> <th class="column1 cbcentered"><input type="checkbox" name="delete_all}" /></th>
<th>{{=T("Filename")}}</th> <th class="column2">{{=T("Filename")}}</th>
<th>{{=T("LineNo")}}</th> <th class="column3">{{=T("Line Nr")}}</th>
<th>{{=T("Temporary")}}</th> <th>{{=T("Temporary")}}</th>
<th>{{=T("Condition")}}</th> <th>{{=T("Condition")}}</th>
<th>{{=T("Hits")}}</th> <th class="columnN">{{=T("Hits")}}</th>
<th></th>
<th></th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
{{for bp in breakpoints:}} {{for bp in breakpoints:}}
<tr class="breakpoint"> <tr class="breakpoint">
<td><input type="checkbox" name="delete_{{=bp['number']}}" /></td> <td class="cbcentered"><input type="checkbox" name="delete_{{=bp['number']}}" /></td>
<td>{{=bp['filename']}}</td> <td>{{=bp['filename']}}</td>
<td>{{=A(bp['lineno'],_href="#",_onclick="collapse('%s');" % bp['number'])}}</td> <td>{{=A(bp['lineno'],_href="#",_onclick="collapse('%s');" % bp['number'])}}</td>
<td>{{=bp['temporary']}}</td> <td>{{=bp['temporary']}}</td>
<td>{{=bp['condition']}}</td> <td>{{=bp['condition']}}</td>
<td>{{=bp['hits']}}</td> <td>{{=bp['hits']}}</td>
</tr> </tr>
<tr id="{{=bp['number']}}" class="sourcecode"> <tr id="{{=bp['number']}}" class="sourcecode traceback">
<td colspan="6"> <td colspan="6">
<div> <div class="ticket_code">
{{=CODE(open(bp['path']).read(), language='python', {{=CODE(open(bp['path']).read(), language='python',
link=None, highlight_line=bp['lineno'], context_lines=10)}} link=None, highlight_line=bp['lineno'], context_lines=10)}}
</div> </div>
@@ -83,32 +96,42 @@ tr.error_ticket:hover {
{{pass}} {{pass}}
</tbody> </tbody>
</table> </table>
</form>
</div> </div>
</div>
<div class="help"> </form><!-- /errorform -->
<ul> </div>
</div>
</div><!-- /applist -->
<div class="sidebar fl60 span5">
<div class="sidebar_inner controls" style="margin:0;">
<div class="box">
<h3>{{=T("Add breakpoint")}}</h3>
{{=form}}
<div class="row-fluid">
<div class="help span12 alert alert-block alert-info">
<ul class="unstyled">
<li>{{=T("You can also set and remove breakpoint in the edit window, using the Toggle Breakpoint button")}}</li> <li>{{=T("You can also set and remove breakpoint in the edit window, using the Toggle Breakpoint button")}}</li>
</ul> </ul>
</div> </div>
</div>
</div>
</div> </div>
</div>
<div class="sidebar fl60">
<div class="sidebar_inner controls">
<div class="box">
<h3>{{=T("Add breakpoint")}}</h3>
{{=form}}
</div>
</div> </div>
</div> </div>
<script type="text/javascript">
jQuery(document).ready(function() {
jQuery('.sourcecode').hide();
jQuery("#trck_breakpoints thead tr th:first input[type=checkbox]").click(function() {
var checkedStatus = this.checked;
jQuery("#trck_breakpoints tbody tr td:first-child input[type=checkbox]").each(function() {
this.checked = checkedStatus;
});
});
jQuery("#trck_breakpoints tbody tr td:first-child input[type=checkbox]").change(function() {
var allchecked = jQuery("#trck_breakpoints tbody tr td:first-child input[type=checkbox]:checked").length == jQuery("#trck_breakpoints tbody tr td:first-child input[type=checkbox]").length;
jQuery("#trck_breakpoints thead tr th:first input[type=checkbox]").prop('checked', allchecked);
});
});
</script>
<!-- end "debug" block -->
+44 -99
View File
@@ -1,113 +1,58 @@
{{extend 'layout.html'}} {{extend 'layout.html'}}
{{block sectionclass}}debug{{end}} {{block sectionclass}}debug{{end}}
<style type="text/css"> <!-- begin "debug" block -->
<div class="row-fluid">
.prompt, #output { <div class="applist f60 span7" style="padding-bottom:20px;">
width: 45em;
height: 1em;
border: 1px solid #CCCCCC;
font-size: 10pt;
margin: 0.5em;
padding: 0.5em;
padding-right: 0em;
overflow: auto;
wrap: hard;
}
#output {
height:150px;overflow:auto;
}
#toolbar {
margin-left: 0.5em;
padding-left: 0.5em;
}
#caret {
width: 2.5em;
margin-right: 0px;
padding-right: 0px;
border-right: 0px;
float: left;
}
#statement {
width: 43em;
margin-left: 1em;
padding-left: 0px;
border-left: 0px;
background-position: top right;
background-repeat: no-repeat;
}
.processing {
background-image: url("{{=URL('static','images/spinner.gif')}}");
}
#ajax-status {
font-weight: bold;
}
.message {
color: #8AD;
font-weight: bold;
font-style: italic;
}
.error {
color: #F44;
}
.username {
font-weight: bold;
}
</style>
<script src="{{=URL('static', 'js/autoscroll.js')}}"></script>
<div class="applist f60">
<div class="applist_inner"> <div class="applist_inner">
<h2>{{=T("web2py online debugger")}}</h2> <h2>{{=T("web2py online debugger")}}</h2>
{{if filename:}} {{if filename:}}
<h3>{{=T("Interaction at %s line %s") % (filename, lineno)}}</h3> <h3 style="word-wrap:break-word;">{{=T("Interaction at %s line %s") % (filename, lineno)}}</h3>
{{if exception:}} {{if exception:}}
<h3 class="exception">{{=T("Exception %s", exception['title'])}}</h3> <h3 class="exception">{{=T("Exception %s", exception['title'])}}</h3>
{{pass}} {{pass}}
<h5>{{=T("Code listing")}}</h5> <h5>{{=T("Code listing")}}</h5>
{{if lines:}} {{if lines:}}<div class="inspect" style="width:100%;overflow:auto;background-color:whiteSmoke;margin-bottom:20px;">
<pre>{{=CODE('\n'.join([x[1] for x in sorted(lines.items(),key=lambda x: x[0])]), <pre>{{=CODE('\n'.join([x[1] for x in sorted(lines.items(),key=lambda x: x[0])]),
language='python', link=None, counter=min(lines.keys()), language='python', link=None, counter=min(lines.keys()),
highlight_line=lineno, context_lines=10)}}</pre> highlight_line=lineno, context_lines=10)}}</pre></div>
{{pass}} {{pass}}
<div class="row-fluid">
<div class="help"> <div class="help span7 alert alert-block alert-info">
<ul> <ul class="unstyled">
<li>{{=T("Your application will be blocked until you click an action button (next, step, continue, etc.)")}}</li> <li>{{=T("Your application will be blocked until you click an action button (next, step, continue, etc.)")}}</li>
<li>{{=T("Your can inspect variables using the console bellow")}}</li> <li>{{=T("Your can inspect variables using the console below")}}</li>
</ul> </ul>
</div> </div>
<h3>{{=T("Interactive console")}}</h3>
<textarea id="output" readonly="readonly">{{=data}}</textarea>
<form id="form" action="{{=URL(r=request,f='execute',args=app)}}" method="get">
<div id="shellwrapper">
<div id="caret">&gt;&gt;&gt;</div>
<div id="autoscroll" style="cursor:pointer;float:right;">autoscroll</div>
<div class="tooltip">
<textarea class="prompt" name="statement" id="statement"></textarea>
<span>{{=T("Type python statement in here and hit Return (Enter) to execute it.")}}</span>
</div> </div>
<h3>{{=T("Interactive console")}}</h3>
<div class="shell"><div id="wrapper">
<div class="row-fluid">
<div class="output-wrapper span11">
<textarea id="output" readonly="readonly">{{=data}}</textarea>
</div>
</div>
<div class="row-fluid">
<form id="form" action="{{=URL(r=request, f='callback', args=app)}}" method="get" class="span11">
<div id="shellwrapper">
<div class="prompt-wrapper">
<div class="prompt-container">
<textarea class="prompt" name="statement" id="statement"></textarea>
</div>
<a href="#" rel="tooltip" data-placement="right" data-original-title="{{=T('Type some Python code in here and hit Return (Enter) to execute it.')}}">
{{=helpicon()}}
<span>Type some Python code in here and hit Return (Enter) to execute it.</span>
</a>
</div>
<div id="caret"><span>&gt;&gt;&gt;</span></div>
<div id="autoscroll">autoscroll</div>
</div> </div>
</form> </form>
</div>
</div></div>
{{elif request.env.get('wsgi_multiprocess') or not request.env.get('wsgi_multithread'):}} {{elif request.env.get('wsgi_multiprocess') or not request.env.get('wsgi_multithread'):}}
<h3 class="not_paused">{{=T("Unsupported webserver working mode: %s", request.env.get('server_software', ''))}}</h3> <h3 class="not_paused">{{=T("Unsupported webserver working mode: %s", request.env.get('server_software', ''))}}</h3>
<div class="help"> <div class="help span7 alert alert-block alert-info">
<ul class="unstyled">
<li><b>{{=T("WARNING:")}} </b>{{=T("This debugger may not work properly if you don't have a threaded webserver or you're using multiple daemon processes.")}}</li> <li><b>{{=T("WARNING:")}} </b>{{=T("This debugger may not work properly if you don't have a threaded webserver or you're using multiple daemon processes.")}}</li>
<li>{{=T("In development, use the default Rocket webserver that is currently supported by this debugger.")}}</li> <li>{{=T("In development, use the default Rocket webserver that is currently supported by this debugger.")}}</li>
<li>{{=T("On production, you'll have to configure your webserver to use one process and multiple threads to use this debugger.")}}</li> <li>{{=T("On production, you'll have to configure your webserver to use one process and multiple threads to use this debugger.")}}</li>
@@ -116,8 +61,8 @@
{{#=BEAUTIFY(request.env)}} {{#=BEAUTIFY(request.env)}}
{{else:}} {{else:}}
<h3 class="not_paused">{{=T("No Interaction yet")}}</h3> <h3 class="not_paused">{{=T("No Interaction yet")}}</h3>
<div class="help"> <div class="help span7 alert alert-block alert-info">
<ul> <ul class="unstyled">
<li>{{=T("You need to set up and reach a")}} {{=A(T("breakpoint"), _href=URL('breakpoints'))}} {{=T('to use the debugger!')}}</li> <li>{{=T("You need to set up and reach a")}} {{=A(T("breakpoint"), _href=URL('breakpoints'))}} {{=T('to use the debugger!')}}</li>
<li>{{=T('To emulate a breakpoint programatically, write:')}} <li>{{=T('To emulate a breakpoint programatically, write:')}}
{{=CODE("from gluon.debug import dbg\n" {{=CODE("from gluon.debug import dbg\n"
@@ -128,12 +73,10 @@
</div> </div>
{{pass}} {{pass}}
</div> </div>
</div> </div> <!-- /applist -->
<div class="sidebar fl60 span5">
<div class="sidebar_inner controls" style="margin:0;">
<div class="sidebar fl60"> <span class="pwdchange pull-right">
<div class="sidebar_inner controls">
<span class="pwdchange">
{{if filename:}} {{if filename:}}
{{=sp_button(URL('step'), T("step"))}} {{=sp_button(URL('step'), T("step"))}}
{{=sp_button(URL('next'), T("next"))}} {{=sp_button(URL('next'), T("next"))}}
@@ -168,6 +111,7 @@
</div> </div>
</div> </div>
<script src="{{=URL('static', 'js/autoscroll.js')}}"></script>
<script type="text/javascript"> <script type="text/javascript">
var bShellScrolling=0 var bShellScrolling=0
@@ -243,4 +187,5 @@ jQuery(document).ready(function(){
}); });
}); });
</script> </script>
</div>
<!-- end "debug" block -->