Opened 9 years ago

Closed 9 years ago

Last modified 7 years ago

#2368 closed defect (fixed)

Error: Macro AddComment(None) failed warning on comment posting

Reported by: giv@… Owned by: Odd Simon Simonsen
Priority: normal Component: AddCommentMacro
Severity: normal Keywords:
Cc: Trac Release: 0.11



2008-01-09 22:32:05,512 Trac[formatter] DEBUG: Executing Wiki macro AddComment by provider <addcomment.macro.AddCommentMacro object at 0x8d7958c>
2008-01-09 22:32:05,518 Trac[formatter] ERROR: Macro AddComment(None) failed
Traceback (most recent call last):
  File "/usr/local/lib/python2.5/site-packages/Trac-0.11b1-py2.5.egg/trac/wiki/", line 465, in _macro_formatter
    return macro.process(args, in_paragraph=True)
  File "/usr/local/lib/python2.5/site-packages/Trac-0.11b1-py2.5.egg/trac/wiki/", line 179, in process
    text = self.processor(text)
  File "/usr/local/lib/python2.5/site-packages/Trac-0.11b1-py2.5.egg/trac/wiki/", line 166, in _macro_processor
  File "build/bdist.freebsd-6.2-RELEASE-i386/egg/addcomment/", line 112, in expand_macro
    req.warning("Comment saved.")
  File "/usr/local/lib/python2.5/site-packages/Trac-0.11b1-py2.5.egg/trac/web/", line 171, in __getattr__
    raise AttributeError(name)
AttributeError: warning

Attachments (0)

Change History (4)

comment:1 Changed 9 years ago by Alec Thomas

Owner: changed from Alec Thomas to Christian Boos

comment:2 Changed 9 years ago by Odd Simon Simonsen

Owner: changed from Christian Boos to Odd Simon Simonsen

I'll look into that. That is the new warning-api I suppose.

comment:3 Changed 9 years ago by Noah Kantrowitz

You should use add_notice(req, 'Comment added').

comment:4 Changed 9 years ago by Odd Simon Simonsen

Resolution: fixed
Status: newclosed

(In [3027]) AddCommentMacro: Warning + req.redirect() issues fixed.

The macro used the first version warning style (req.warning()), but that was just a left-over from before moving to redirect on successful submit anyway - it would not have displayed to the user no matter what. The line is just removed. Fixes #2368.

The whole req.redirect() idea needed to be reworked as macros cannot really do redirects. A redirect raises RequestDone, and like all other exceptions from macros it gets swallowed by the Formatter - causing an AssertionError to appear in the logs when the request tries to write a second status/header/response output later.

The exception did not display to the user, but was annoying... Now the redirect sets a marker on the req object, and by implementing IRequestFilter it now re-raises the RequestDone there.

Modify Ticket

Change Properties
Set your email in Preferences
as closed The owner will remain Odd Simon Simonsen.
The resolution will be deleted. Next status will be 'reopened'.

Add Comment

E-mail address and name can be saved in the Preferences.

Note: See TracTickets for help on using tickets.