Modify

Opened 7 years ago

Closed 7 years ago

Last modified 4 years ago

#2368 closed defect (fixed)

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

Reported by: giv@… 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 7 years ago by athomas

  • Owner changed from athomas to cboos

comment:2 Changed 7 years ago by osimons

  • Owner changed from cboos to osimons

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

comment:3 Changed 7 years ago by coderanger

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

comment:4 Changed 7 years ago by osimons

  • Resolution set to fixed
  • Status changed from new to 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.

Add Comment

Modify Ticket

Action
as closed .
as The resolution will be set. Next status will be 'closed'.
to The owner will be changed from osimons. Next status will be 'closed'.
The resolution will be deleted. Next status will be 'reopened'.
Author


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

 
Note: See TracTickets for help on using tickets.