Firing (displaying) a warning message from my plug-in

18 views
Skip to first unread message

Cybernium

unread,
Oct 30, 2012, 8:42:48 AM10/30/12
to trac-...@googlegroups.com
Hi,
as mentioned in the tittle, I'm trying to stop the flow of my algorithm to display a warning message
and wait until the user response ...! is it possible to implement that ?
I saw that there was  something like that in trac.web.chrome.add_warning(req, msg, *args) but
I don't have any idea how to implement that  ?


Any ideas ?
Thanks

RjOllos

unread,
Oct 30, 2012, 1:28:16 PM10/30/12
to trac-...@googlegroups.com
On Tuesday, October 30, 2012 5:42:48 AM UTC-7, Cybernium wrote:
Hi,
as mentioned in the tittle, I'm trying to stop the flow of my algorithm to display a warning message
and wait until the user response ...! is it possible to implement that ?

It depends what you mean by "wait until the user response". If you want blocking behavior, then one (maybe the only?) option is to use a JavaScript dialog.
 
I saw that there was  something like that in trac.web.chrome.add_warning(req, msg, *args) but
I don't have any idea how to implement that  ?

What interfaces does your plugin implement? If you are IRequestHandler or IRequestFilter, among others, you can add the following in process_request or post_process_request:

from trac.web.chrome import add_warning
add_warning(req, "Warning message goes here")

Cybernium

unread,
Oct 31, 2012, 4:44:35 AM10/31/12
to trac-...@googlegroups.com
Thank you for your answer.
I'm trying the javascript way. I think it will work with .
But for the sake of knowing how can implement use "post_process_request" actually more than
what does this function ? maybe it' more efficient than my actual solution.
(I'm using IRequestHandler  interface )
Thanks a lot

RjOllos

unread,
Oct 31, 2012, 12:57:56 PM10/31/12
to trac-...@googlegroups.com
On Wednesday, October 31, 2012 1:44:35 AM UTC-7, Cybernium wrote:
Thank you for your answer.
I'm trying the javascript way. I think it will work with .
But for the sake of knowing how can implement use "post_process_request" actually more than
what does this function ? maybe it' more efficient than my actual solution.
(I'm using IRequestHandler  interface )
Thanks a lot

`post_process_request` allows, among other things, for some data to be passed or a script to be added to a request that is handled by another component. If you wanted to add some javascript to the newticket page, for example, then you could do that by calling `add_script` in `post_process_request`, after checking that the `req.path_info`was "newticket".

I'd suggest studying some examples of trac-hacks. Here is one such example, which adds javascript and a contextual navigation entry to the ticket and newticket pages:

Cybernium

unread,
Nov 9, 2012, 5:47:43 AM11/9/12
to trac-...@googlegroups.com
Thanks :)
Reply all
Reply to author
Forward
0 new messages