| 15 | The fields on a model object can be edited by treating the object as a dictionary. If you change any of the fields you must call save_changes() to have them persisted. |
| 16 | |
| 17 | To edit a ticket... |
| 18 | {{{ |
| 19 | #!python |
| 20 | import trac.env |
| 21 | import trac.ticket.model |
| 22 | |
| 23 | # Open Trac environment |
| 24 | t = trac.env.Environment("path/to/trac/env") |
| 25 | |
| 26 | # Get the ticket you are after (how can we query for tickets?) |
| 27 | myticket = trac.ticket.model.Ticket(t, tkt_id=1) |
| 28 | |
| 29 | # Read a ticket field |
| 30 | print "Changing description for ticket called %s" %myticket["summary"] |
| 31 | |
| 32 | #Write a ticket field |
| 33 | myticket["description"] = "My ticket now has a new description." |
| 34 | |
| 35 | #Save your changes |
| 36 | myticket.save_changes("myusername","Just changed the description") |
| 37 | }}} |
| 38 | |