Ticket #1420: pastebin-debug1.patch

File pastebin-debug1.patch, 5.6 KB (added by jpaulofarias at gmail dot com, 18 years ago)

Patch to show a pastebin version of traceback (better look)

  • D:/projetos/django_magicremoval/django/views/debug.py

     
    255255      hideAll(getElementsByClassName(document, 'table', 'vars'));
    256256      hideAll(getElementsByClassName(document, 'ol', 'pre-context'));
    257257      hideAll(getElementsByClassName(document, 'ol', 'post-context'));
     258      hideAll(getElementsByClassName(document, 'div', 'pastebin'));
    258259    }
    259260    function toggle() {
    260261      for (var i = 0; i < arguments.length; i++) {
     
    273274      s.innerHTML = s.innerHTML == uarr ? darr : uarr;
    274275      return false;
    275276    }
     277   
     278    function switchPastebinFriendly(link) {
     279      s1 = "switch to pastebin friendly";
     280      s2 = "switch back to browser look";
     281      link.innerHTML = link.innerHTML == s1 ? s2 : s1;
     282      toggle('browserTraceback', 'pastebinTraceback');
     283      return false;
     284    }
    276285    //-->
    277286  </script>
    278287</head>
     
    341350{% endif %}
    342351<div id="traceback">
    343352  <h2>Traceback <span>(innermost last)</span></h2>
    344   <ul class="traceback">
    345     {% for frame in frames %}
    346       <li class="frame">
    347         <code>{{ frame.filename }}</code> in <code>{{ frame.function }}</code>
    348 
    349         {% if frame.context_line %}
    350           <div class="context" id="c{{ frame.id }}">
    351             {% if frame.pre_context %}
    352               <ol start="{{ frame.pre_context_lineno|add:"1" }}" class="pre-context" id="pre{{ frame.id }}">{% for line in frame.pre_context %}<li onclick="toggle('pre{{ frame.id }}', 'post{{ frame.id }}')">{{ line|escape }}</li>{% endfor %}</ol>
    353             {% endif %}
    354             <ol start="{{ frame.lineno|add:"1" }}" class="context-line"><li onclick="toggle('pre{{ frame.id }}', 'post{{ frame.id }}')">{{ frame.context_line|escape }} <span>...</span></li></ol>
    355             {% if frame.post_context %}
    356               <ol start='{{ frame.lineno|add:"2" }}' class="post-context" id="post{{ frame.id }}">{% for line in frame.post_context %}<li onclick="toggle('pre{{ frame.id }}', 'post{{ frame.id }}')">{{ line|escape }}</li>{% endfor %}</ol>
    357             {% endif %}
    358           </div>
    359         {% endif %}
    360 
    361         {% if frame.vars %}
    362           <div class="commands">
    363               <a href="#" onclick="return varToggle(this, '{{ frame.id }}')"><span>&#x25b6;</span> Local vars</a>
    364           </div>
    365           <table class="vars" id="v{{ frame.id }}">
    366             <thead>
    367               <tr>
    368                 <th>Variable</th>
    369                 <th>Value</th>
    370               </tr>
    371             </thead>
    372             <tbody>
    373               {% for var in frame.vars|dictsort:"0" %}
     353  <div class="commands"><a href="#" onclick="return switchPastebinFriendly(this);">switch to pastebin friendly</a></div>
     354  <br/>
     355  <div id="browserTraceback">
     356    <ul class="traceback">
     357      {% for frame in frames %}
     358        <li class="frame">
     359          <code>{{ frame.filename }}</code> in <code>{{ frame.function }}</code>
     360 
     361          {% if frame.context_line %}
     362            <div class="context" id="c{{ frame.id }}">
     363              {% if frame.pre_context %}
     364                <ol start="{{ frame.pre_context_lineno|add:"1" }}" class="pre-context" id="pre{{ frame.id }}">{% for line in frame.pre_context %}<li onclick="toggle('pre{{ frame.id }}', 'post{{ frame.id }}')">{{ line|escape }}</li>{% endfor %}</ol>
     365              {% endif %}
     366              <ol start="{{ frame.lineno|add:"1" }}" class="context-line"><li onclick="toggle('pre{{ frame.id }}', 'post{{ frame.id }}')">{{ frame.context_line|escape }} <span>...</span></li></ol>
     367              {% if frame.post_context %}
     368                <ol start='{{ frame.lineno|add:"2" }}' class="post-context" id="post{{ frame.id }}">{% for line in frame.post_context %}<li onclick="toggle('pre{{ frame.id }}', 'post{{ frame.id }}')">{{ line|escape }}</li>{% endfor %}</ol>
     369              {% endif %}
     370            </div>
     371          {% endif %}
     372 
     373          {% if frame.vars %}
     374            <div class="commands">
     375                <a href="#" onclick="return varToggle(this, '{{ frame.id }}')"><span>&#x25b6;</span> Local vars</a>
     376            </div>
     377            <table class="vars" id="v{{ frame.id }}">
     378              <thead>
    374379                <tr>
    375                   <td>{{ var.0 }}</td>
    376                   <td class="code"><div>{{ var.1|pprint|escape }}</div></td>
     380                  <th>Variable</th>
     381                  <th>Value</th>
    377382                </tr>
    378               {% endfor %}
    379             </tbody>
    380           </table>
    381         {% endif %}
    382       </li>
    383     {% endfor %}
    384   </ul>
     383              </thead>
     384              <tbody>
     385                {% for var in frame.vars|dictsort:"0" %}
     386                  <tr>
     387                    <td>{{ var.0 }}</td>
     388                    <td class="code"><div>{{ var.1|pprint|escape }}</div></td>
     389                  </tr>
     390                {% endfor %}
     391              </tbody>
     392            </table>
     393          {% endif %}
     394        </li>
     395      {% endfor %}
     396    </ul>
     397  </div>
     398  <div id="pastebinTraceback" class="pastebin">
     399    <table>
     400      <tbody>
     401        <tr>
     402          <td>
     403            <code>
     404{% for frame in frames %}
     405  {{ frame.filename }} in {{ frame.function }}<br/>
     406  {% if frame.context_line %}
     407    &nbsp;&nbsp;{{ frame.lineno|add:"1" }}. {{ frame.context_line|escape }}<br/>
     408  {% endif %}
     409{% endfor %}<br/>
     410&nbsp;&nbsp;{{ exception_type }} at {{ request.path }}<br/>
     411&nbsp;&nbsp;{{ exception_value|escape }}</code>
     412          </td>
     413        </tr>
     414      </tbody>
     415    </table>
     416  </div>
    385417</div>
    386418
    387419<div id="requestinfo">
Back to Top