change comment on submit

26 views
Skip to first unread message

Markus Rosjat

unread,
Apr 25, 2023, 9:34:05 AM4/25/23
to trac-...@googlegroups.com
hi all,

Is it possible to change the content of a comment on submit? I know I can hook in to ticket changed event but how do I pass the changes along ? Do I need to hook into some other method (from an interface) or do it by "hand" accessing the database?

cheers

Markus

Jun Omae

unread,
Apr 27, 2023, 3:12:15 AM4/27/23
to trac-...@googlegroups.com
Hi,
It is able to validate the comment using
ITicketManipulator.validate_comment() at
https://trac.edgewall.org/browser/tags/trac-1.4.3/trac/ticket/api.py#L178.
However, it is unable to change the comment using the
ITicketManipulator.

Instead, try to replace req.args['comment'] using
IRequestFilter.pre_process_request() when receiveing POST.

--
Jun Omae <jun...@gmail.com> (大前 潤)

Markus Rosjat

unread,
Apr 27, 2023, 8:31:29 AM4/27/23
to trac-...@googlegroups.com
thanks for the advice i will check it out!

cheers

Markus


--
You received this message because you are subscribed to the Google Groups "Trac Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to trac-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/trac-users/CAEVLMahGywNOMMLW-mTWvm86jjYAFywFFr59TqkyLyLZK4GrMA%40mail.gmail.com.

RjOllos

unread,
May 8, 2023, 8:13:11 AM5/8/23
to Trac Users
On Thursday, April 27, 2023 at 2:31:29 PM UTC+2 markus...@gmail.com wrote:
thanks for the advice i will check it out!

cheers

Markus

Markus Rosjat

unread,
May 8, 2023, 8:39:06 AM5/8/23
to trac-...@googlegroups.com
Hi,

i got my code working now, its a mix of WikiMacroBase expand_macro and IRequestFilter. So now i can use a macro to add some stuff in the comment and on commit it will resolve the macro and plug it into the comment so the macro is removed with informations that need to be persistent.

I know it sounds strange but the idea behind it is to add stuff like date and authenticated user in the comment with the expand macro in the preview and later replace the macro code wit the string that is shown in the preview to make it persistent. if i would leave the macro it would always take the actual date and the user that is logged in and that defeats the purpose here.

Cheers

Markus


--
You received this message because you are subscribed to the Google Groups "Trac Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to trac-users+...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages