Skip to content
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 IWorkspaceCreatedFromTemplateEvent #17

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion collective/auditlog/action.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@
except ImportError:
class IPloneFormGenField(Interface):
pass
try:
from ploneintranet.workspace.interfaces import IWorkspaceCreatedFromTemplateEvent # noqa: E501
except ImportError:
class IWorkspaceCreatedFromTemplateEvent(Interface):
pass

from Products.Archetypes.interfaces import (
IObjectInitializedEvent, IObjectEditedEvent, IBaseObject)
Expand Down Expand Up @@ -120,7 +125,8 @@ def __call__(self):
action = 'removed'
elif (IObjectInitializedEvent.providedBy(event) or
IObjectCreatedEvent.providedBy(event) or
IObjectAddedEvent.providedBy(event)):
IObjectAddedEvent.providedBy(event) or
IWorkspaceCreatedFromTemplateEvent.providedBy(event)):
action = 'added'
elif IObjectMovedEvent.providedBy(event):
# moves can also be renames. Check the parent object
Expand Down
5 changes: 5 additions & 0 deletions collective/auditlog/configure.zcml
Original file line number Diff line number Diff line change
Expand Up @@ -104,4 +104,9 @@
handler=".handlers.execute_event"
/>

<subscriber
for="ploneintranet.workspace.interfaces.IWorkspaceCreatedFromTemplateEvent"
handler=".handlers.execute_event"
/>

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this subscriber be moved to ploneintranet?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right, collective.auditlog should also work without ploneintranet, so either this needs to be wrapped in a condition or moved elsewhere. On the other hand ploneintranet is also independent from collective.auditlog, so we would need a condition there as well. Then there's the fact that we already have the conditional import here in action.py

I don't think there's a completely clean way to do it. If you prefer I'll move the subscriber to ploneintranet.

</configure>
3 changes: 2 additions & 1 deletion docs/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ Changelog
1.3.4 (unreleased)
------------------

- Nothing changed yet.
- Handle IWorkspaceCreatedFromTemplateEvent.
[reinhardt]


1.3.3 (2018-07-12)
Expand Down