let ExternalSourceInfo delegate to a corresponding adapter on the 'adapted()' object when retrieving external identifier
This commit is contained in:
parent
1b62d9948c
commit
6b6ee7024d
1 changed files with 9 additions and 3 deletions
|
@ -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
|
# 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
|
# 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.
|
Managing information form objects provided by external sources, e.g. loops.agent.
|
||||||
|
|
||||||
$Id$
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from persistent.mapping import PersistentMapping
|
from persistent.mapping import PersistentMapping
|
||||||
|
@ -27,6 +25,7 @@ from zope import interface, component
|
||||||
from zope.interface import implements
|
from zope.interface import implements
|
||||||
from zope.component import adapts
|
from zope.component import adapts
|
||||||
|
|
||||||
|
from loops.common import adapted
|
||||||
from loops.interfaces import ILoopsObject
|
from loops.interfaces import ILoopsObject
|
||||||
from loops.integrator.interfaces import IExternalSourceInfo
|
from loops.integrator.interfaces import IExternalSourceInfo
|
||||||
|
|
||||||
|
@ -46,6 +45,13 @@ class ExternalSourceInfo(object):
|
||||||
return getattr(self.context, sourceInfoAttrName, PersistentMapping())
|
return getattr(self.context, sourceInfoAttrName, PersistentMapping())
|
||||||
|
|
||||||
def getExternalIdentifier(self):
|
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')
|
return self.getSourceInfo().get('externalIdentifier')
|
||||||
def setExternalIdentifier(self, value):
|
def setExternalIdentifier(self, value):
|
||||||
info = self.getSourceInfo()
|
info = self.getSourceInfo()
|
||||||
|
|
Loading…
Add table
Reference in a new issue