Edgewall Software
Modify

Opened 16 years ago

Closed 16 years ago

Last modified 16 years ago

#7216 closed defect (fixed)

TracQuery macro failing with {'stylesheet': ...} has no member named 'next'

Reported by: davidf@… Owned by: Christian Boos
Priority: normal Milestone: 0.11
Component: wiki system Version: 0.11rc1
Severity: normal Keywords: macro
Cc: davidf@… Branch:
Release Notes:
API Changes:
Internal Changes:

Description

These errors started appearing after an upgrade from an earlier 0.11 release to the latest svn (just after rc1 - r7003 on the 0.11 branch):

Error: Macro TicketQuery(iteration=current&status!=closed&type!=specification|responsibility|project&col=id&col=summary&col=status&col=type&col=priority&col=milestone&order=priority&group=owner,format=table) failed

{'stylesheet': [{'href': '/chrome/common/css/report.css', 'type': 'text/css', 'class': None, 'title': None}]} has no member named "next"

The slightly abbreviated traceback is here:

2008-05-05 08:10:30,250 Trac[formatter] ERROR: Macro TicketQuery(iteration=current&status=closed&type!=responsibility|project&col=id&col=summary&col=status&col=type&col=priority&col=milestone&col=owner&order=priority&group=component,format=table) failed
Traceback (most recent call last):
  File "/usr/lib/python2.4/site-packages/trac/wiki/formatter.py", line 468, in _macro_formatter
    return macro.process(args, in_paragraph=True)

[snip]

  File "/usr/lib/python2.4/site-packages/genshi/template/directives.py", line 680, in __call__
    value = expr.evaluate(ctxt)
  File "/usr/lib/python2.4/site-packages/genshi/template/eval.py", line 136, in evaluate
    return eval(self.code, _globals, {'data': data})
  File "/usr/lib/python2.4/site-packages/trac/templates/page_index.html", line 21, in <Expression '?'>
    <span py:if="paginator.has_next_page"
  File "/usr/lib/python2.4/site-packages/genshi/template/eval.py", line 281, in lookup_item
    return obj[key]
  File "/usr/lib/python2.4/site-packages/genshi/template/eval.py", line 236, in _die
    raise UndefinedError(self._name, self._owner)
UndefinedError: {'stylesheet': [{'href': '/chrome/common/css/report.css', 'type': 'text/css', 'class': None, 'title': None}]} has no member named "next"

It's not entirely dependent on the query and so I suspect it's got something to do with the number of records being returned (it's from the paginator).

The actual expression generated isn't in the traceback, but in the template:

    <span py:if="paginator.has_next_page"
          py:with="nextlink = chrome.links.next[0]" class="next">

I can help debug if some pointers are given… this is within a standard wiki page, and the TracQuery macro expression was:

TicketQuery(iteration=current&status!=closed&type!=specification|responsibility|project&col=id&col=summary&col=status&col=type&col=priority&col=milestone&order=priority&group=owner,format=table)

Attachments (0)

Change History (8)

comment:1 by Christian Boos, 16 years ago

How many matches and how many results per page?

in reply to:  1 comment:2 by anonymous, 16 years ago

Replying to cboos:

How many matches and how many results per page?

The error doesn't account for 90 matches, and does for 111, and the number of results per page when going through the View Tickets / custom query system is 100… This error only occurs with format=table from within a wiki page - surely the correct thing within a wiki page query is to have no paging?

comment:3 by davidf@…, 16 years ago

Having looked through the code, manually setting max=0 makes this work - should this be made the default for TracQuery calls? The alternative of trying to make them do paging within a wiki page seems much more complex…

comment:4 by Christian Boos, 16 years ago

The idea was to allow the max parameter to be used so that the number of tickets shown can be limited (there used to be a limit argument), but with no pagination support (the differentiator should be req == None in the case a Query is called from the TicketQuery macro).

in reply to:  4 comment:5 by anonymous, 16 years ago

Replying to cboos:

The idea was to allow the max parameter to be used so that the number of tickets shown can be limited (there used to be a limit argument), but with no pagination support (the differentiator should be req == None in the case a Query is called from the TicketQuery macro).

Yes, that makes sense - req == None is passed through to Query.template_data, but to fix this we should probably

  • handle Pagination construction differently in the if req: section Also the Query
  • the Query constructor sets max to items_per_page by default - ideally this should be done in the call to Paginator only if there is a req

But I don't know the code that well so I'm just guessing…

comment:6 by Christian Boos, 16 years ago

Resolution: fixed
Status: newclosed

Thanks for your feedback, the issue should be fixed now in [7055].

comment:7 by Christian Boos, 16 years ago

Woops, commit was on the wrong branch - I backported to 0.11-stable in [7059].

comment:8 by davidf@…, 16 years ago

Yay, working nicely - thanks cboos

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Christian Boos.
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from Christian Boos 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.