<!DOCTYPE html
    PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:py="http://genshi.edgewall.org/"
      xmlns:xi="http://www.w3.org/2001/XInclude">
  <xi:include href="layout.html" />
  <head>
    <title>${title or 'Error'}</title>
    <script py:if="frames" type="text/javascript">/*<![CDATA[*/
      jQuery(document).ready(function($) {
        $("#traceback a").click(function() {
          $("div", this.parentNode).slideToggle("fast");
          return false;
        });
        $("#tbtoggle").click(function() {
          if (this.value.indexOf("interactive") < 0) {
            this.value = "Switch to interactive view";
            $("#traceback ul").fadeOut("fast", function() {
              $("#traceback pre").fadeIn("fast");
            });
          } else {
            this.value = "Switch to plain text view";
            $("#traceback pre").fadeOut("fast", function() {
              $("#traceback ul").fadeIn("fast");
            });
          }
          return false;
        });
       /* Only activate interactive view if Javascript is enabled */
       $("#traceback ul").show();
       $("#traceback pre").hide();
       $("#tbtoggle").parent().show();
       
       $("#systeminfo").append("<tr><th>jQuery:</th><td>"+$().jquery+"</td></tr>");
       $("#systeminfo").before("<p>User Agent: <tt>"+navigator.userAgent+"</tt></p>");
      });
    /*]]>*/</script>
    <script type="text/javascript">/*<![CDATA[*/
      jQuery(document).ready(function($) {
       var descr = $("#description").text();
       descr = descr.replace(/==== System Information ====\s+/m,
         "User Agent was: `" + navigator.userAgent + "`\n\n$&"
       );
       descr = descr.replace(/\|\|\s+==== Python Traceback ====/m,
         "||\n|| '''jQuery:''' || `" + $().jquery + "` $&"
       );
       $("#description").text(descr);
      });
    /*]]>*/</script>
  </head>

  <py:def function="create_ticket(teo=False)">
    <input type="hidden" name="reporter" value="${get_reporter_id(req)}" />
    <input py:if="teo" type="hidden" name="version"
           value="${'dev' in trac.version and 'devel' or trac.version}" />
    <input type="hidden" name="summary" value="$message" />
    <textarea id="description" name="description" rows="3" cols="10">

==== How to Reproduce ====

While doing a $req.method operation on `$req.path_info`, Trac issued an internal error.

''(please provide additional details here)''

<py:if test="req.args">
Request parameters:
{{{
${pprint(req.args)}
}}}
</py:if>

==== System Information ====
<py:for each="k, v in trac.systeminfo">
|| '''$k''' || ${'`%s`' % (v and v.replace('\n', '` [[br]] `'))} ||</py:for>

==== Python Traceback ====
{{{
${traceback}
}}}
    </textarea>
    <span class="inlinebuttons">
      <input type="submit" name="create" value="Create" />
    </span>
  </py:def>

  <body>
    <div id="content" class="error">
      <py:choose test="type">
        <py:when test="'TracError'">
          <h1>$title</h1>
          <py:choose test="">
            <p py:when="istext(message)" class="message">$message</p>
            <py:otherwise>$message</py:otherwise>
          </py:choose>
        </py:when>
        <py:when test="'internal'">
          <h1>Oops&hellip;</h1>
          <div class="message">
            <strong>Trac detected an internal error:</strong>
            <pre>$message</pre>
          </div>
          <py:choose>
            <py:when test="'TRAC_ADMIN' not in perm">
              <p>There was an internal error in Trac. It is recommended
              that you inform your local
              <a py:strip="not project.admin" href="mailto:${project.admin}">Trac
              administrator</a> and give him all the information he needs to
              reproduce the issue.
              </p>
              <form py:if="project.admin_href"
                    class="newticket" method="get" action="${project.admin_href.newticket()}#">
                <p>To that end, you could ${create_ticket()} a ticket.</p>
              </form>
              <p>The action that triggered the error was:</p>
              <pre>${req.method}: ${req.path_info}</pre>
            </py:when>
            <py:otherwise>
              <form class="newticket" method="get" action="${project.admin_href.newticket()}#">
                <p>This is probably a local installation issue.
                  <py:if test="project.admin_href and project.admin_trac_url != '.'">
                    You should ${create_ticket()} a ticket at the admin Trac to report
                    the issue.
                  </py:if>
                </p>
              </form>
              <h2>Found a bug in Trac?</h2>
              <p>If you think this should work and you can reproduce the problem,
              you should consider reporting this to the Trac team.</p>
              <p>Before you do that, though, <strong>please first try
                <a py:with="q = quote_plus(message[:80])"
                   href="${trac.homepage}search?ticket=yes&amp;noquickjump=1&amp;q=$q">searching</a>
                for similar issues</strong>, as it is quite likely that this problem
                has been reported before. For questions about installation
                and configuration of Trac, please try the
                <a href="${trac.homepage}wiki/MailingList">mailing list</a>
                instead of filing a ticket.
              </p>
              <form class="newticket" method="get" action="${trac.homepage}newticket">
                <p>Otherwise, please ${create_ticket(True)} a new ticket at
                the Trac project site, where you can describe the problem and
                explain how to reproduce it.</p>
              </form>
              <py:if test="traceback">
                <h2>Python Traceback</h2>
                <div id="traceback">
                  Most recent call last:
                  <ul py:if="frames" style="display: none">
                    <li class="frame" py:for="idx, frame in enumerate(frames)">
                      <a href="#frame${idx}" id="frame${idx}">
                        <span class="file">File "${frame.filename}",
                        line <b>${frame.lineno + 1}</b>, in</span>
                        <var>${frame.function}</var>
                      </a>
                      <div py:if="frame.line" class="source" style="display: none">
                        <h3>Code fragment:</h3>
                        <ol start="${frame.lineno + 1 - len(frame.lines_before)}">
                          <li py:for="line in frame.lines_before"><code>${line or u'\xa0'}</code></li>
                          <li class="current"><code>${frame.line or u'\xa0'}</code></li>
                          <li py:for="line in frame.lines_after"><code>${line or u'\xa0'}</code></li>
                        </ol>
                      </div>
                      <div py:if="frame.vars" class="vars" style="display: none">
                        <h3>Local variables:</h3>
                        <table class="listing">
                          <thead><tr><th>Name</th><th>Value</th></tr></thead>
                          <tbody>
                            <tr py:for="idx, (name, value) in enumerate(sorted(frame.vars.items()))"
                                class="${idx % 2 and 'odd' or None}">
                              <th scope="row"><var>$name</var></th>
                              <td><code>${shorten_line(repr(value))}</code></td>
                            </tr>
                          </tbody>
                        </table>
                      </div>
                    </li>
                  </ul>
                  <pre><py:for each="frame in frames">File "${frame.filename}", line ${frame.lineno + 1}, in ${frame.function}<py:if test="frame.line">
  ${frame.line.lstrip()}
</py:if></py:for><py:if test="not frames">${traceback}</py:if></pre>
                  <p style="display: none"><input type="button" id="tbtoggle" value="Switch to plain text view" /></p>
                </div>
              </py:if>
              <h2>System Information:</h2>
              <table class="listing" id="systeminfo">
                <tr py:for="name, value in trac.systeminfo">
                  <th>$name:</th>
                  <td>$value</td>
                </tr>
              </table>
            </py:otherwise>
          </py:choose>
        </py:when>
      </py:choose>
      <p>
        <a href="${href.wiki('TracGuide')}">TracGuide</a> &mdash; The Trac User and Administration Guide
      </p>
    </div>
  </body>
</html>
