From 6b6ee7024d52ad2dd360b8e85caed9d82d3c6120 Mon Sep 17 00:00:00 2001 From: Helmut Merz Date: Thu, 17 Nov 2011 11:19:56 +0100 Subject: [PATCH] let ExternalSourceInfo delegate to a corresponding adapter on the 'adapted()' object when retrieving external identifier --- integrator/source.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/integrator/source.py b/integrator/source.py index 8be2737..788e685 100644 --- a/integrator/source.py +++ b/integrator/source.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2007 Helmut Merz helmutm@cy55.de +# Copyright (c) 2011 Helmut Merz helmutm@cy55.de # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -18,8 +18,6 @@ """ Managing information form objects provided by external sources, e.g. loops.agent. - -$Id$ """ from persistent.mapping import PersistentMapping @@ -27,6 +25,7 @@ from zope import interface, component from zope.interface import implements from zope.component import adapts +from loops.common import adapted from loops.interfaces import ILoopsObject from loops.integrator.interfaces import IExternalSourceInfo @@ -46,6 +45,13 @@ class ExternalSourceInfo(object): return getattr(self.context, sourceInfoAttrName, PersistentMapping()) def getExternalIdentifier(self): + # first try to find adapter on adapted concept or resource + adapted = adapted(self.context) + if adapted != self.context: + adaptedSourceInfo = IExternalSourceInfo(adapted, None) + if adaptedSourceInfo is not None: + return adaptedSourceInfo.getExternalIdentifier() + # otherweise use stored external identifier return self.getSourceInfo().get('externalIdentifier') def setExternalIdentifier(self, value): info = self.getSourceInfo()