-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Handle custom events #18
Comments
I think that custom events can be handled by registering a more specific adapter: collective.auditlog/collective/auditlog/action.py Lines 53 to 57 in 20d5949
You can register an adapter that inherits from |
I would have to override the whole |
Well, a patch is effective for every context, action, event combination, a ZCA registered adapter is not. |
...but still pretty much all the rest of the original method. See my examples above. Also, if two packages have custom events and each registers an adapter override, one will "win" and blot out the other. I was hoping to get to some kind of plugin structure where multiple packages could contribute events/actions. |
Anyway, I'll try to take a first step by refactoring the if/else block a little. That should be helpful in any case. |
I would just put the if block in other method for a start, this will already simplify things a lot. |
Yes. |
Well, you have to provide the proper interfaces... Patches are even worse from this point of view. |
How do I do that if I don't happen to control all of the third party packages?
No discussion there. The point of this ticket is to get rid of the need to patch. |
I am sorry I cannot see where the problem is :( |
You're right that I can do an adapter override and that this has certain advantages over a patch. I just think that the advantages aren't big enough in this case to justify using an adapter. Currently we already have an overriden adapter in a customer package. I would now create another adapter override in an intermediary package. That would however be ignored because the customer package would still use its own adapter. So I would have to change the customer adapter to derive from the intermediary adapter, or at least in some way make sure the code from both packages is used. If I think that a little further I end up with a stack of dependent adapters, and if I break one of them everything topples over. |
I think this is not more a thing after #20 is merged. |
We would like to have the possibility to let custom events trigger an audit log entry. It is already possible to register the appropriate event handler for a custom event, but no audit log entry will be created. This is because AuditActionExecutor hard codes checks for a number of interfaces on the event and discards events that don't match.
I image registering adapters or utilities for events that return an action verb ('added', 'modified', ...) and other hints about how this event needs to be logged. Maybe the way plone.app.contentrules registers rule names for events can be an inspiration.
The text was updated successfully, but these errors were encountered: