let DummyRelationRegistry use real IntIds if available

git-svn-id: svn://svn.cy55.de/Zope3/src/cybertools/trunk@1415 fd906abe-77d9-0310-91a1-e0d9ade77398
This commit is contained in:
helmutm 2006-10-21 17:49:31 +00:00
parent 36acb9d8cf
commit 06dc2c17fb

View file

@ -24,6 +24,7 @@ $Id$
from persistent import Persistent
from persistent.interfaces import IPersistent
from zope import component
from zope.interface import Interface, Attribute, implements
from zope.app import zapi
from zope.app.catalog.catalog import Catalog
@ -54,7 +55,11 @@ class DummyRelationRegistry(object):
self.objects.append(relation)
for attr in ('first', 'second', 'third',):
value = getattr(relation, attr, None)
if value is not None and value not in self.objects:
if value is not None:
intids = component.queryUtility(IIntIds)
if intids is not None:
intids.register(value)
elif value not in self.objects:
self.objects.append(value)
def unregister(self, relation):
@ -65,6 +70,9 @@ class DummyRelationRegistry(object):
def getUniqueIdForObject(self, obj):
if obj == '*': # wild card
return '*'
intids = component.queryUtility(IIntIds)
if intids is not None:
return intids.register(obj)
if obj not in self.objects:
self.objects.append(obj)
return self.objects.index(obj)