Trees | Indices | Help |
|
---|
|
1 ########################################################################### 2 # 3 # This program is part of Zenoss Core, an open source monitoring platform. 4 # Copyright (C) 2010, Zenoss Inc. 5 # 6 # This program is free software; you can redistribute it and/or modify it 7 # under the terms of the GNU General Public License version 2 or (at your 8 # option) any later version as published by the Free Software Foundation. 9 # 10 # For complete information please visit: http://www.zenoss.com/oss/ 11 # 12 ########################################################################### 13 import logging 14 from zope.event import notify 15 from zope.component import adapter 16 from zope.interface import implements 17 from zope.component.interfaces import ObjectEvent 18 from zope.container.interfaces import IObjectMovedEvent, IObjectRemovedEvent 19 from OFS.interfaces import IObjectWillBeMovedEvent, IObjectWillBeAddedEvent 20 from .interfaces import IGUIDEvent, IGUIDManager, IGloballyIdentifiable 21 from .interfaces import IGlobalIdentifier 22 23 log = logging.getLogger('zen.UUID') 3337 mgr = IGUIDManager(object) 38 if event.new: 39 mgr.setObject(event.new, object) 40 if event.update_global_catalog: 41 try: 42 catalog = object.global_catalog 43 catalog.catalog_object(object, idxs=(), update_metadata=True) 44 except Exception: 45 log.exception('Encountered a guid exception') 46 if event.old and event.old != event.new: 47 # When we move a component around, 48 # we don't want to remove the guid 49 # from the catalog 50 if mgr.getPath(event.old) == object.getPrimaryUrlPath(): 51 mgr.remove(event.old)5253 54 @adapter(IGloballyIdentifiable, IObjectMovedEvent) 55 -def refireEventOnObjectAddOrMove(object, event):56 if not IObjectRemovedEvent.providedBy(event): 57 oldguid = IGlobalIdentifier(object).getGUID() 58 if oldguid is None: 59 IGlobalIdentifier(object).create() 60 else: 61 # Refire in the case where an object already has a guid 62 # but that guid has been removed from the guid table 63 notify(GUIDEvent(object, oldguid, oldguid))6465 66 @adapter(IGloballyIdentifiable, IObjectWillBeMovedEvent) 67 -def refireEventOnObjectBeforeRemove(object, event):71
Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1.1812 on Tue Oct 11 12:51:40 2011 | http://epydoc.sourceforge.net |