slight improvement relation/tests/IntIdsStub: now registers on get
git-svn-id: svn://svn.cy55.de/Zope3/src/cybertools/trunk@1128 fd906abe-77d9-0310-91a1-e0d9ade77398
This commit is contained in:
parent
d8aac7ee60
commit
e6c94efa08
1 changed files with 4 additions and 4 deletions
|
@ -15,7 +15,7 @@ from cybertools.relation.interfaces import IRelationRegistry
|
||||||
from cybertools.relation.registry import RelationRegistry
|
from cybertools.relation.registry import RelationRegistry
|
||||||
|
|
||||||
|
|
||||||
class IntIdsStub:
|
class IntIdsStub(object):
|
||||||
"""A testing stub (mock utility) for IntIds."""
|
"""A testing stub (mock utility) for IntIds."""
|
||||||
implements(IIntIds)
|
implements(IIntIds)
|
||||||
|
|
||||||
|
@ -25,14 +25,14 @@ class IntIdsStub:
|
||||||
def getObject(self, uid):
|
def getObject(self, uid):
|
||||||
return self.objs[uid]
|
return self.objs[uid]
|
||||||
|
|
||||||
def getId(self, ob):
|
|
||||||
return self.objs.index(ob)
|
|
||||||
|
|
||||||
def register(self, ob):
|
def register(self, ob):
|
||||||
if ob not in self.objs:
|
if ob not in self.objs:
|
||||||
self.objs.append(ob)
|
self.objs.append(ob)
|
||||||
return self.objs.index(ob)
|
return self.objs.index(ob)
|
||||||
|
|
||||||
|
getId = register
|
||||||
|
queryId = getId
|
||||||
|
|
||||||
def unregister(self, ob):
|
def unregister(self, ob):
|
||||||
id = self.getId(ob)
|
id = self.getId(ob)
|
||||||
self.objs[id] = None
|
self.objs[id] = None
|
||||||
|
|
Loading…
Add table
Reference in a new issue