fix check for adapter in 'externalIdentifier'

This commit is contained in:
Helmut Merz 2017-10-08 12:44:04 +02:00
parent 6a685187d5
commit d863305b94

View file

@ -1,5 +1,5 @@
# #
# Copyright (c) 2011 Helmut Merz helmutm@cy55.de # Copyright (c) 2017 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
@ -25,7 +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.common import adapted, AdapterBase
from loops.interfaces import ILoopsObject from loops.interfaces import ILoopsObject
from loops.integrator.interfaces import IExternalSourceInfo from loops.integrator.interfaces import IExternalSourceInfo
@ -39,6 +39,7 @@ class ExternalSourceInfo(object):
adapts(ILoopsObject) adapts(ILoopsObject)
def __init__(self, context): def __init__(self, context):
#import pdb; pdb.set_trace()
self.context = self.__parent__ = context self.context = self.__parent__ = context
def getSourceInfo(self): def getSourceInfo(self):
@ -47,7 +48,9 @@ class ExternalSourceInfo(object):
def getExternalIdentifier(self): def getExternalIdentifier(self):
# first try to find adapter on adapted concept or resource # first try to find adapter on adapted concept or resource
adobj = adapted(self.context) adobj = adapted(self.context)
if adobj != self.context: #if adobj != self.context:
#if not adobj is self.context:
if isinstance(adobj, AdapterBase):
adaptedSourceInfo = IExternalSourceInfo(adobj, None) adaptedSourceInfo = IExternalSourceInfo(adobj, None)
if adaptedSourceInfo is not None: if adaptedSourceInfo is not None:
return adaptedSourceInfo.externalIdentifier return adaptedSourceInfo.externalIdentifier