Discussion:
[Trac-dev] ITicketTypeChangeListener?
Theodor Norup
2016-12-17 19:45:12 UTC
Permalink
I am maintaining a plugin (SubticketsPlugin) that has configuration values
that are per-ticket-type. I'd like to improve the plugin to use the Options
interface so that its configuration becomes editable through the IniAdmin
plugin.

However, to do that properly, first of all I need to enumerate all
available ticket types and I cannot find an api function for that.

Secondly, I need to detect addition of new ticket types. Had there been an
extension point like the IMilestoneChangeListener it had been easy...

Suggestions on alternative ways to proceed are very welcome. Other plugins
with per-ticket-type configuration could benefit too.

BTW, I'm aware of the discussion in https://trac.edgewall.org/ticket/11148
which suggests the future existence of an ITypeChangeListener interface,
but unfortunately that has not been integrated in the main line.

Thanks in advance.

T.
--
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
2016-12-17 20:53:46 UTC
Permalink
Post by Theodor Norup
I am maintaining a plugin (SubticketsPlugin) that has configuration values
that are per-ticket-type. I'd like to improve the plugin to use the Options
interface so that its configuration becomes editable through the IniAdmin
plugin.
What values will you be storing in trac.ini? Are the values currently
stored in the database?
Post by Theodor Norup
However, to do that properly, first of all I need to enumerate all
available ticket types and I cannot find an api function for that.
from trac.env import Environment
from trac.ticket.model import Type as TicketType
env =
Environment('/Users/rjollos/Documents/Workspace/trac-dev/tracenvs/proj-1.0')
... print(t.name, t.value)
...
(u'defect', u'1')
(u'enhancement', u'2')
(u'task', u'3')
Post by Theodor Norup
Secondly, I need to detect addition of new ticket types. Had there been an
extension point like the IMilestoneChangeListener it had been easy...
Suggestions on alternative ways to proceed are very welcome. Other plugins
with per-ticket-type configuration could benefit too.
BTW, I'm aware of the discussion in https://trac.edgewall.org/ticket/11148
<https://www.google.com/url?q=https%3A%2F%2Ftrac.edgewall.org%2Fticket%2F11148&sa=D&sntz=1&usg=AFQjCNH52C67SdMwxOIqdhUDqmgAiuRuoA>
which suggests the future existence of an ITypeChangeListener interface,
but unfortunately that has not been integrated in the main line.
Yeah #11148 is sorely needed, and revisiting that is high on my priority
list.

For now, I think you'll have to use IRequestFilter:
https://trac.edgewall.org/wiki/TracDev/PluginDevelopment/ExtensionPoints/trac.web.api.IRequestFilter

That won't notify you in the case that the Ticket Type is added using
trac-admin. I don't see a way to handle that scenario, short of
implementing #11148.
Post by Theodor Norup
Thanks in advance.
T.
- 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.
Theodor Norup
2016-12-18 10:27:00 UTC
Permalink
Thanks, that will bring me quite close to a reasonable implementation
although a slight performance penalty will be slapped onto each and every
request.

The config values to be stored are not in the database today - it is stuff
like the list of subticket fields to be displayed in the subtickets table,
which fields to inherit when creating subtickets, etc. And more to come.

BR T.
Post by RjOllos
Post by Theodor Norup
I am maintaining a plugin (SubticketsPlugin) that has configuration
values that are per-ticket-type. I'd like to improve the plugin to use the
Options interface so that its configuration becomes editable through the
IniAdmin plugin.
What values will you be storing in trac.ini? Are the values currently
stored in the database?
Post by Theodor Norup
However, to do that properly, first of all I need to enumerate all
available ticket types and I cannot find an api function for that.
from trac.env import Environment
from trac.ticket.model import Type as TicketType
env =
Environment('/Users/rjollos/Documents/Workspace/trac-dev/tracenvs/proj-1.0')
... print(t.name, t.value)
...
(u'defect', u'1')
(u'enhancement', u'2')
(u'task', u'3')
Post by Theodor Norup
Secondly, I need to detect addition of new ticket types. Had there been
an extension point like the IMilestoneChangeListener it had been easy...
Suggestions on alternative ways to proceed are very welcome. Other
plugins with per-ticket-type configuration could benefit too.
BTW, I'm aware of the discussion in
https://trac.edgewall.org/ticket/11148
<https://www.google.com/url?q=https%3A%2F%2Ftrac.edgewall.org%2Fticket%2F11148&sa=D&sntz=1&usg=AFQjCNH52C67SdMwxOIqdhUDqmgAiuRuoA>
which suggests the future existence of an ITypeChangeListener interface,
but unfortunately that has not been integrated in the main line.
Yeah #11148 is sorely needed, and revisiting that is high on my priority
list.
https://trac.edgewall.org/wiki/TracDev/PluginDevelopment/ExtensionPoints/trac.web.api.IRequestFilter
That won't notify you in the case that the Ticket Type is added using
trac-admin. I don't see a way to handle that scenario, short of
implementing #11148.
Post by Theodor Norup
Thanks in advance.
T.
- 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...