Trac - How do I access Custom Ticket Fields in ITicketChangeListener?

亡梦爱人 提交于 2019-12-25 06:51:08

问题


I'm trying to write my own Trac plugin to notify an external system of changes to tickets matching a certain criteria. From my research so far, I've figured out that implementing the ITicketChangeListener interface is the way to go.

The method definitions are all very straight forward, but what's not straight forward for me is the Ticket object and accessing its custom fields. I've learned that you can access default ticket fields as simply as:

# t is a Ticket object
theStatus = t['status']

I've found several sources that say this won't work:

myCustomField = t['my_custom_field']

Yet none of them tell me what will work.

In addition, I need to know if the old_values argument of the ticket_changed() method will have my custom fields or if I'll have to do something different there as well.

I'm fairly new to Python and very new to Trac. Any help to point me in the right direction is appreciated.


回答1:


The sources are wrong about custom ticket fields. The value-by-name approach should work. And *old_values* contains all fields values, including custom fields too. That's it.

You may want to look at the TracAnnouncer source for some change-listener coding examples.



来源:https://stackoverflow.com/questions/9503401/trac-how-do-i-access-custom-ticket-fields-in-iticketchangelistener

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!