forked from senaite/senaite.core
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fire notifications when UID references are created/destroyed (senaite…
…#2061) * Fire notifications when references are created/destroyed * Changelog updated * Docstring added
- Loading branch information
Showing
4 changed files
with
80 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
from zope.interface import implementer | ||
from zope.interface.interfaces import IObjectEvent | ||
|
||
|
||
class IUIDReferenceCreatedEvent(IObjectEvent): | ||
"""An event fired after a reference between two objects was cretated | ||
""" | ||
|
||
|
||
class IUIDReferenceDestroyedEvent(IObjectEvent): | ||
"""An event fired after a reference between two objects was destroyed | ||
""" | ||
|
||
|
||
@implementer(IUIDReferenceCreatedEvent) | ||
class UIDReferenceCreated(object): | ||
|
||
def __init__(self, field, source, target): | ||
"""Reference Created Event | ||
:param field: The field on the source object | ||
:param source: The context object holding the UID reference field | ||
:param target: The context object being referenced | ||
""" | ||
self.field = field | ||
self.source = source | ||
self.target = target | ||
|
||
# See IObjectEvent | ||
# -> Allow to define an event subscriber for a custom type | ||
self.object = source | ||
|
||
|
||
@implementer(IUIDReferenceDestroyedEvent) | ||
class UIDReferenceDestroyed(object): | ||
|
||
def __init__(self, field, source, target): | ||
"""Reference Destroyed Event | ||
:param field: The field on the source object | ||
:param source: The context object holding the UID reference field | ||
:param target: The context object being referenced | ||
""" | ||
self.field = field | ||
self.source = source | ||
self.target = target | ||
|
||
# See IObjectEvent | ||
# -> Allow to define an event subscriber for a custom type | ||
self.object = source |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters