--- a/src/pyams_utils/intids.py Wed Nov 20 19:26:23 2019 +0100
+++ b/src/pyams_utils/intids.py Fri Nov 22 18:51:37 2019 +0100
@@ -10,26 +10,29 @@
# FOR A PARTICULAR PURPOSE.
#
-__docformat__ = 'restructuredtext'
-
+"""PyAMS_utils.intids module
-# import standard packages
+This module provides utility functions and helpers to help usage of IIntIds utilities.
+Pyramid events subscribers are also declared to match Zope events with Pyramid IntIds related
+events
+"""
-# import interfaces
from persistent.interfaces import IPersistent
-from pyams_utils.interfaces.intids import IUniqueID
-from zope.intid.interfaces import IIntIds, IIntIdEvent, IntIdAddedEvent, IntIdRemovedEvent
-from zope.lifecycleevent.interfaces import IObjectAddedEvent, IObjectRemovedEvent
-from zope.location.interfaces import ISublocations
-from zope.keyreference.interfaces import IKeyReference, NotYet
-
-# import packages
-from pyams_utils.adapter import adapter_config, ContextAdapter
-from pyams_utils.registry import get_all_utilities_registered_for, query_utility
from pyramid.events import subscriber
from pyramid.threadlocal import get_current_registry
from zope.intid import intIdEventNotify
+from zope.intid.interfaces import IIntIdEvent, IIntIds, IntIdAddedEvent, IntIdRemovedEvent
+from zope.keyreference.interfaces import IKeyReference, NotYet
from zope.lifecycleevent import ObjectRemovedEvent
+from zope.lifecycleevent.interfaces import IObjectAddedEvent, IObjectRemovedEvent
+from zope.location.interfaces import ISublocations
+
+from pyams_utils.adapter import ContextAdapter, adapter_config
+from pyams_utils.interfaces.intids import IUniqueID
+from pyams_utils.registry import get_all_utilities_registered_for, query_utility
+
+
+__docformat__ = 'restructuredtext'
@adapter_config(context=IPersistent, provides=IUniqueID)
@@ -46,6 +49,7 @@
intids = query_utility(IIntIds)
if intids is not None:
return hex(intids.queryId(self.context))[2:]
+ return None
@subscriber(IObjectAddedEvent, context_selector=IPersistent)
@@ -82,7 +86,7 @@
registry = get_current_registry()
locations = ISublocations(event.object, None)
if locations is not None:
- for location in locations.sublocations():
+ for location in locations.sublocations(): # pylint: disable=too-many-function-args
registry.notify(ObjectRemovedEvent(location))
utilities = tuple(get_all_utilities_registered_for(IIntIds))
if utilities:
@@ -100,7 +104,9 @@
@subscriber(IIntIdEvent)
def handle_intid_event(event):
- """Event subscriber used to dispatch all IIntIdEvent events using Pyramid events subscribers to matching
- subscribers using Zope events
+ """IntId event subscriber
+
+ This event is used to dispatch all IIntIdEvent events using Pyramid events subscribers
+ to matching subscribers using Zope events
"""
intIdEventNotify(event)