#2368 closed defect (fixed)
Error: Macro AddComment(None) failed warning on comment posting
| Reported by: | Owned by: | osimons | |
|---|---|---|---|
| Priority: | normal | Component: | AddCommentMacro | 
| Severity: | normal | Keywords: | |
| Cc: | Trac Release: | 0.11 | 
Description
Trac-0.11b1
TracAddCommentMacro-0.3
TracMacroPost-0.2
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/formatter.py", 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/formatter.py", line 179, in process
    text = self.processor(text)
  File "/usr/local/lib/python2.5/site-packages/Trac-0.11b1-py2.5.egg/trac/wiki/formatter.py", line 166, in _macro_processor
    text)
  File "build/bdist.freebsd-6.2-RELEASE-i386/egg/addcomment/macro.py", 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/api.py", line 171, in __getattr__
    raise AttributeError(name)
AttributeError: warning
    Attachments (0)
Change History (4)
comment:1 Changed 18 years ago by
| Owner: | changed from Alec Thomas to Christian Boos | 
|---|
comment:2 Changed 18 years ago by
| Owner: | changed from Christian Boos to osimons | 
|---|
comment:4 Changed 18 years ago by
| Resolution: | → fixed | 
|---|---|
| Status: | new → closed | 
(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.



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