Discussion:
[Trac-dev] Question regarding validate ticket on ticket_created
Logan Anderson
2017-03-03 16:13:25 UTC
Permalink
Hey guys,

It appears that I can validate fields for a ticket via validate_ticket and if I use if req.path_info ('/newticket' to detect it from new ticket entry but this doesn't catch new tickets created in other ways such as via the RPC. Ok, so I can detect new ticket creation with ticket_created, but this doesn't seem to allow me to adjust the field values. It seems to trigger after the ticket is created and doesn't intercept the request allowing me to adjust the fields before submission.

I hope that makes sense. How do I appropriately detect a *new ticket* and alter the fields before it is saved as I do with validate_ticket?

I was looking for more info on the req object. Maybe I don't know how to search for what I want in the API document. Is there something in there which I can use from within validate_ticket to detect that it is a new ticket (from whatever source) and avoid making the adjustments for ticket updates?


Thanks,
Logan
--
You received this message because you are subscribed to the Google Groups "Trac Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to trac-dev+***@googlegroups.com.
To post to this group, send email to trac-***@googlegroups.com.
Visit this group at https://groups.google.com/group/trac-dev.
For more options, visit https://groups.google.com/d/optout.
RjOllos
2017-03-03 23:41:10 UTC
Permalink
Post by Logan Anderson
Hey guys,
It appears that I can validate fields for a ticket via validate_ticket and
if I use if req.path_info ('/newticket' to detect it from new ticket entry
but this doesn't catch new tickets created in other ways such as via the
RPC. Ok, so I can detect new ticket creation with ticket_created, but this
doesn't seem to allow me to adjust the field values. It seems to trigger
after the ticket is created and doesn't intercept the request allowing me
to adjust the fields before submission.
I hope that makes sense. How do I appropriately detect a *new ticket* and
alter the fields before it is saved as I do with validate_ticket?
I was looking for more info on the req object. Maybe I don't know how to
search for what I want in the API document. Is there something in there
which I can use from within validate_ticket to detect that it is a new
ticket (from whatever source) and avoid making the adjustments for ticket
updates?
Thanks,
Logan
You can alter the ticket fields in validate_ticket. As an example you can
look at r11747 for DefaultCcPlugin. Prior to r11747 ITicketChangeListener
was used to append to the CC list, but this resulted in additional entries
in the change history of the ticket. r11747 switched to using
ITicketManipulator to append to the CC list before the ticket is created.

https://trac-hacks.org/changeset/11747

- Ryan
--
You received this message because you are subscribed to the Google Groups "Trac Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to trac-dev+***@googlegroups.com.
To post to this group, send email to trac-***@googlegroups.com.
Visit this group at https://groups.google.com/group/trac-dev.
For more options, visit https://groups.google.com/d/optout.
Logan Anderson
2017-03-07 14:02:20 UTC
Permalink
Thank you for your response.

What I was specifically hoping for was a solution within validate_ticket to detect that it is a new ticket specifically. I can check req.path_info in ('/newticket') but that doesn't capture new tickets created via the RPC or other methods.





From: "RjOllos" <***@gmail.com>
To: "Trac Development" <trac-***@googlegroups.com>
Cc: ***@clacorp.com
Sent: Friday, March 3, 2017 6:41:10 PM
Subject: [Trac-dev] Re: Question regarding validate ticket on ticket_created



On Friday, March 3, 2017 at 8:14:21 AM UTC-8, Logan Anderson wrote:


Hey guys,

It appears that I can validate fields for a ticket via validate_ticket and if I use if req.path_info ('/newticket' to detect it from new ticket entry but this doesn't catch new tickets created in other ways such as via the RPC. Ok, so I can detect new ticket creation with ticket_created, but this doesn't seem to allow me to adjust the field values. It seems to trigger after the ticket is created and doesn't intercept the request allowing me to adjust the fields before submission.

I hope that makes sense. How do I appropriately detect a *new ticket* and alter the fields before it is saved as I do with validate_ticket?

I was looking for more info on the req object. Maybe I don't know how to search for what I want in the API document. Is there something in there which I can use from within validate_ticket to detect that it is a new ticket (from whatever source) and avoid making the adjustments for ticket updates?


Thanks,
Logan




You can alter the ticket fields in validate_ticket. As an example you can look at r11747 for DefaultCcPlugin. Prior to r11747 ITicketChangeListener was used to append to the CC list, but this resulted in additional entries in the change history of the ticket. r11747 switched to using ITicketManipulator to append to the CC list before the ticket is created.

https://trac-hacks.org/changeset/11747

- Ryan
--
You received this message because you are subscribed to the Google Groups "Trac Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to trac-dev+***@googlegroups.com .
To post to this group, send email to trac-***@googlegroups.com .
Visit this group at https://groups.google.com/group/trac-dev .
For more options, visit https://groups.google.com/d/optout .
--
You received this message because you are subscribed to the Google Groups "Trac Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to trac-dev+***@googlegroups.com.
To post to this group, send email to trac-***@googlegroups.com.
Visit this group at https://groups.google.com/group/trac-dev.
For more options, visit https://groups.google.com/d/optout.
RjOllos
2017-03-07 18:22:27 UTC
Permalink
Post by Logan Anderson
Thank you for your response.
What I was specifically hoping for was a solution within validate_ticket
to detect that it is a new ticket specifically. I can check req.path_info
in ('/newticket') but that doesn't capture new tickets created via the RPC
or other methods.
ITicketManipulators aren't called by XmlRpcPlugin:
https://trac-hacks.org/ticket/10738

I think there is some relevant discussion about this in #11148, but I
haven't looked at that ticket in a while.
https://trac.edgewall.org/ticket/11148

Within validate_ticket it is easy enough to test whether you are dealing
with a new ticket: in addition to checking "req.path_info == /newticket"
you can use "ticket.exists". However it sounds like your issue is that
validate_ticket is not called by XmlRpcPlugin.

Note that the behavior of ITicketChangeListener is different from
ITicketManipulator, but it should still be called when creating a ticket
via XmlRpcPlugin.

- Ryan
--
You received this message because you are subscribed to the Google Groups "Trac Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to trac-dev+***@googlegroups.com.
To post to this group, send email to trac-***@googlegroups.com.
Visit this group at https://groups.google.com/group/trac-dev.
For more options, visit https://groups.google.com/d/optout.
Logan Anderson
2017-03-07 19:20:23 UTC
Permalink
aaahhh....


Thank you.


From: "RjOllos" <***@gmail.com>
To: "Trac Development" <trac-***@googlegroups.com>
Cc: ***@clacorp.com
Sent: Tuesday, March 7, 2017 1:22:27 PM
Subject: Re: [Trac-dev] Re: Question regarding validate ticket on ticket_created

On Tuesday, March 7, 2017 at 6:03:19 AM UTC-8, Logan Anderson wrote:


Thank you for your response.

What I was specifically hoping for was a solution within validate_ticket to detect that it is a new ticket specifically. I can check req.path_info in ('/newticket') but that doesn't capture new tickets created via the RPC or other methods.




ITicketManipulators aren't called by XmlRpcPlugin:
https://trac-hacks.org/ticket/10738

I think there is some relevant discussion about this in #11148, but I haven't looked at that ticket in a while.
https://trac.edgewall.org/ticket/11148

Within validate_ticket it is easy enough to test whether you are dealing with a new ticket: in addition to checking "req.path_info == /newticket" you can use "ticket.exists". However it sounds like your issue is that validate_ticket is not called by XmlRpcPlugin.

Note that the behavior of ITicketChangeListener is different from ITicketManipulator, but it should still be called when creating a ticket via XmlRpcPlugin.

- Ryan
--
You received this message because you are subscribed to the Google Groups "Trac Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to trac-dev+***@googlegroups.com.
To post to this group, send email to trac-***@googlegroups.com.
Visit this group at https://groups.google.com/group/trac-dev.
For more options, visit https://groups.google.com/d/optout.
Loading...