Where do those messages come from?

17 views
Skip to first unread message

Christopher Nelson

unread,
Aug 21, 2012, 9:32:16 PM8/21/12
to trac...@googlegroups.com
Now and then a ticket validator or some other code I'm not sure of
displays a message at the top of a ticket after I commit changes. I
want to do that in my plugin but I have no idea what function to use.
Can someone point me at an example? Thanks!


Chris
--
A: Top-posting.
Q: What is the most annoying thing in e-mail?

Dirk Stöcker

unread,
Aug 22, 2012, 2:45:50 AM8/22/12
to trac...@googlegroups.com
On Tue, 21 Aug 2012, Christopher Nelson wrote:

> Now and then a ticket validator or some other code I'm not sure of
> displays a message at the top of a ticket after I commit changes. I
> want to do that in my plugin but I have no idea what function to use.
> Can someone point me at an example? Thanks!

Like this:

class MyPageValidator(Component):

implements(IWikiPageManipulator)

def prepare_wiki_page(self, req, page, fields):
pass

def validate_wiki_page(self, req, page):
if page.name == "MyName":
if not req.perm.has_permission('WIKI_ADMIN'):
... check a lot
return [(None, "You are not allowed to change this!")]
try:
... check something else
except Exception, e:
return [(None, "Data validation failed")]
return []

Ciao
--
http://www.dstoecker.eu/ (PGP key available)

Grzegorz Sobanski

unread,
Aug 22, 2012, 7:37:09 AM8/22/12
to trac...@googlegroups.com
W dniu środa, 22 sierpnia 2012 03:32:16 UTC+2 użytkownik Chris Nelson napisał:
Now and then a ticket validator or some other code I'm not sure of
displays a message at the top of a ticket after I commit changes.  I
want to do that in my plugin but I have no idea what function to use.
Can someone point me at an example?  Thanks!


 from trac.web.chrome import add_notice, add_warning

and then when you are handling request, just call:

 add_notice(req, u'It was done, sir.')
 add_warning(req, u'Boo boo')

Christopher Nelson

unread,
Aug 22, 2012, 7:41:02 AM8/22/12
to trac...@googlegroups.com
>> Now and then a ticket validator or some other code I'm not sure of
>> displays a message at the top of a ticket after I commit changes. I
>> want to do that in my plugin but I have no idea what function to use.
>> Can someone point me at an example? Thanks!
>...
> class MyPageValidator(Component):
>
> implements(IWikiPageManipulator)
>...

Thanks but I want to do it in a ticket change listener, not for a wiki page.

Willmer, Alex (PTS)

unread,
Aug 22, 2012, 8:00:57 AM8/22/12
to trac...@googlegroups.com
The equivalent for tickets is ITicketManipulator. For the API and examples, see

http://www.edgewall.org/docs/branches-0.12-stable/epydoc/trac.ticket.api.ITicketManipulator-class.html
http://trac.edgewall.org/wiki/TracDev/PluginDevelopment/ExtensionPoints/trac.ticket.api.ITicketManipulator

Regards, Alex
--
You received this message because you are subscribed to the Google Groups "Trac Development" group.
To post to this group, send email to trac...@googlegroups.com.
To unsubscribe from this group, send email to trac-dev+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/trac-dev?hl=en.



Think green - keep it on the screen.

This e-mail and any attachment is for authorised use by the intended recipient(s) only. It may contain proprietary material, confidential information and/or be subject to legal privilege. It should not be copied, disclosed to, retained or used by, any other party. If you are not an intended recipient then please promptly delete this e-mail and any attachment and all copies and inform the sender. Thank you.


Christopher Nelson

unread,
Aug 22, 2012, 8:04:19 AM8/22/12
to trac...@googlegroups.com
> ...
> from trac.web.chrome import add_notice, add_warning
>
> and then when you are handling request, just call:
>
> add_notice(req, u'It was done, sir.')
> add_warning(req, u'Boo boo')

Perfect! Thanks.
Reply all
Reply to author
Forward
0 new messages