On 10/23/23 22:57, Abhilash Raj wrote:
On 10/23/23 20:37, Thomas Ward via Mailman-users wrote:
I want to add a custom handler that implements customized thread IDs in the system. I already have the DB logic worked out, but the documentation for plugins is NOT clear on how to define a handler in a plugin, nor does the example plugin in the documentation on Gitlab have any custom handlers.
I'm looking to add a custom handler so that the private pipeline for threaded-subject-list can use thread-subject (the custom handler) instead of subject-prefix (builtin).
https://gitlab.com/mailman/mailman/-/tree/master/src/mailman/plugins/testing...
https://docs.mailman3.org/projects/mailman/en/latest/src/mailman/plugins/doc...
These are two places you can find docs for an example plugin that ships with Mailman's code. Adding a new "component", like a Handler, works very similar to the "rules" in the example shown above. Yeah these're helpful, but the problem I was running into was file naming schema - I was not aware it's always PLUGIN/COMPONENT/COMPONENT.py in the naming, which it was not entirely clear about. It makes sense now that I look back, but it never hurts to get clarification.
You will probably need a directory tree like:
example/ __init__.py hooks.py handlers/ __init__.py handlers.py
Installing the handler is same as per shown in docs using below (do note that the above example is the name of the package that is importable):
<snip>
Finally, you can verify that your handler was loaded properly using something along the lines of:
$ mailman shell Welcome to the GNU Mailman shell Use commit() to commit changes. Use abort() to discard changes since the last commit. Exit with ctrl+D does an implicit commit() but exit() does not. >>> for each in config.handlers: ... print(each) ... <snip>
The only other thing that was missing is how to set up the proper code for a Handler implementation/class, which I used an existing mailman3 core plugin as an example to just run with for testing purposes.
There are notes in the example plugin on Gitlab and the documentation that "other components will be added as examples eventually" but that was well over a year ago, so we'll see how that ages.
Thanks for the assist!
Thomas