Edgewall Software
Modify

Opened 11 years ago

Closed 11 years ago

#11357 closed defect (worksforme)

IndexError: list index out of range

Reported by: admin Owned by:
Priority: normal Milestone:
Component: general Version: 0.12.2
Severity: normal Keywords:
Cc: Ryan J Ollos Branch:
Release Notes:
API Changes:
Internal Changes:

Description

How to Reproduce

While doing a GET operation on /ticket/181, Trac issued an internal error.

I am trying to edit an existing comment by clicking on the Edit button resulting in this error.

Request parameters:

{'cnum_edit': u'1', 'id': u'181'}

User agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:25.0) Gecko/20100101 Firefox/25.0

System Information

Trac 0.12.2
Babel 0.9.6 (translations unavailable)
Docutils 0.8.1
Genshi 0.6
mod_wsgi 3.3 (WSGIProcessGroup WSGIApplicationGroup %{GLOBAL})
Pygments 1.4
pysqlite 2.6.0
Python 2.7.3 (default, Sep 26 2013, 20:13:52)
[GCC 4.6.3]
pytz 2011k
setuptools 0.6
SQLite 3.7.9
Subversion 1.6.17 (r1128011)
jQuery 1.4.2

Enabled Plugins

TracAccountManager 0.4.3

Python Traceback

Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/trac/web/main.py", line 511, in _dispatch_request
    dispatcher.dispatch(req)
  File "/usr/lib/python2.7/dist-packages/trac/web/main.py", line 258, in dispatch
    content_type)
  File "/usr/lib/python2.7/dist-packages/trac/web/chrome.py", line 868, in render_template
    stream.render(method, doctype=doctype, out=buffer)
  File "/usr/lib/python2.7/dist-packages/genshi/core.py", line 183, in render
    return encode(generator, method=method, encoding=encoding, out=out)
  File "/usr/lib/python2.7/dist-packages/genshi/output.py", line 58, in encode
    for chunk in iterator:
  File "/usr/lib/python2.7/dist-packages/genshi/output.py", line 339, in __call__
    for kind, data, pos in stream:
  File "/usr/lib/python2.7/dist-packages/genshi/output.py", line 826, in __call__
    for kind, data, pos in stream:
  File "/usr/lib/python2.7/dist-packages/genshi/output.py", line 670, in __call__
    for kind, data, pos in stream:
  File "/usr/lib/python2.7/dist-packages/genshi/output.py", line 771, in __call__
    for kind, data, pos in chain(stream, [(None, None, None)]):
  File "/usr/lib/python2.7/dist-packages/genshi/output.py", line 586, in __call__
    for ev in stream:
  File "/usr/lib/python2.7/dist-packages/genshi/core.py", line 288, in _ensure
    for event in stream:
  File "/usr/lib/python2.7/dist-packages/genshi/core.py", line 288, in _ensure
    for event in stream:
  File "/usr/lib/python2.7/dist-packages/trac/web/chrome.py", line 981, in _strip_accesskeys
    for kind, data, pos in stream:
  File "/usr/lib/python2.7/dist-packages/genshi/core.py", line 288, in _ensure
    for event in stream:
  File "/usr/lib/python2.7/dist-packages/trac/web/chrome.py", line 970, in _generate
    for kind, data, pos in stream:
  File "/usr/lib/python2.7/dist-packages/genshi/template/base.py", line 605, in _include
    for event in stream:
  File "/usr/lib/python2.7/dist-packages/genshi/template/markup.py", line 378, in _match
    ctxt, start=idx + 1, **vars):
  File "/usr/lib/python2.7/dist-packages/genshi/template/markup.py", line 378, in _match
    ctxt, start=idx + 1, **vars):
  File "/usr/lib/python2.7/dist-packages/genshi/template/markup.py", line 341, in _match
    if test(event, namespaces, ctxt) is True:
  File "/usr/lib/python2.7/dist-packages/genshi/path.py", line 129, in _test
    pos_queue = deque([(pos, cou, []) for pos, cou in stack[-1]])
IndexError: list index out of range

Attachments (0)

Change History (5)

comment:1 by Ryan J Ollos, 11 years ago

Cc: Ryan J Ollos added

Genshi:#523 shows a similar stack trace. Do you have any site template customizations?

comment:2 by anonymous, 11 years ago

You are correct. The only change to our bog standard install of trac was that a colleague has added the following code (found with google) to ticket.html to have the "Modify ticket" section expanded by default:

<div py:match="div[@id='content' and @class='ticket']//div[@id='modify']" py:attrs="select('@*')">
  ${select('*|comment()|text()')}
  <script type="text/javascript">
    jQuery(document).ready(function($) {
      $("#modify").parent().removeClass("collapsed");
    });
  </script>
</div>

Without this code editting an existing comment works fine.

However we very much would like to keep the "Modify ticket" section expanded by default. Do you know of a better way that doesn't interfere with editting comments?

comment:3 by Ryan J Ollos, 11 years ago

You probably found the code in comment:18:ticket:9807. I can reproduce the traceback you've shown with the current Trac 1.0-stable and Genshi 0.6, 0.6.1 and 0.7 when the snippet is placed within the head or body elements of ticket.html. The snippet is intended to go in site.html though.

In your environment directory, you should find templates/site.html.sample. You can either put the snippet in that file and rename it to site.html, or equivalently, create a new file site.html and put the following content in it:

<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:xi="http://www.w3.org/2001/XInclude"
      xmlns:py="http://genshi.edgewall.org/"
      py:strip="">
  <div py:match="div[@id='content' and @class='ticket']//div[@id='modify']" py:attrs="select('@*')">
    ${select('*|comment()|text()')}
    <script type="text/javascript">
      jQuery(document).ready(function($) {
        $("#modify").parent().removeClass("collapsed");
      });
    </script>
  </div>
</html>

That assumes you don't already have content in a site.html file, in which case you just want to add your snippet inside the html tags of the existing file.

comment:4 by anonymous, 11 years ago

Thank you for your very helpful suggestion. I did vary a little on your solution however.

For legacy reasons we have multiple trac enviroments and I didn't really feel like creating multiple site.html files. That's why I created a shared templates/site.html and modified the trac.ini files of the enviroments to use this shared templates directory with the templates_dir option of the [inherit] section.

As far as I can tell this works great. The "Modify ticket" sections are still expanded by default and editting comments is now possible without errors.

As the problem is solved to satisfaction I think you can close this ticket. Once again thank you for your kind help.

comment:5 by Ryan J Ollos, 11 years ago

Resolution: worksforme
Status: newclosed

I'm glad it is working for you. Thanks for the feedback.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The ticket will remain with no owner.
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from (none) to the specified user.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.