Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save masaki/988228 to your computer and use it in GitHub Desktop.
Save masaki/988228 to your computer and use it in GitHub Desktop.
Trac XmlRpcPlugin and validate_ticket extension point
diff --git a/tracrpc/ticket.py b/tracrpc/ticket.py
index 6224276..3042718 100644
--- a/tracrpc/ticket.py
+++ b/tracrpc/ticket.py
@@ -237,14 +237,13 @@ class TicketRPC(Component):
req.args['comment'] = comment
req.args['ts'] = time_changed
changes, problems = tm.get_ticket_changes(req, t, action)
- for warning in problems:
- add_warning(req, "Rpc ticket.update: %s" % warning)
- valid = problems and False or tm._validate_ticket(req, t)
- if not valid:
- raise TracError(
- " ".join([warning for warning in req.chrome['warnings']]))
+ if problems:
+ for warning in problems:
+ add_warning(req, "Rpc ticket.update: %s" % warning)
+ raise TracError(" ".join([warning for warning in req.chrome['warnings']]))
else:
tm._apply_ticket_changes(t, changes)
+ tm._validate_ticket(req, t) # validate after apply changes
self.log.debug("Rpc ticket.update save: %s" % repr(t.values))
t.save_changes(author, comment, when=when)
# Apply workflow side-effects
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment