linK: Python3 fixes

This commit is contained in:
Helmut Merz 2024-09-22 14:46:28 +02:00
parent 383b77edf1
commit c9220d834d
3 changed files with 10 additions and 31 deletions

View file

@ -43,7 +43,7 @@ of its attributes.
>>> (l01.identifier, l01.source, l01.target, l01.name, l01.linkType, l01.state, >>> (l01.identifier, l01.source, l01.target, l01.name, l01.linkType, l01.state,
... l01.relevance, l01.order) ... l01.relevance, l01.order)
(1, 0, 1, 'p2', u'link', u'valid', 1.0, 0) (1, 0, 1, 'p2', 'link', 'valid', 1.0, 0)
Query for links Query for links
--------------- ---------------

View file

@ -1,25 +1,6 @@
# # cybertools.link.base
# 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
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
""" """ A simple generic, general-purpose link management framework.
A simple generic, general-purpose link management framework.
$Id$
""" """
from BTrees.IFBTree import intersection, union from BTrees.IFBTree import intersection, union
@ -28,18 +9,17 @@ from persistent import Persistent
from zope import component from zope import component
from zope.component import adapts from zope.component import adapts
from zope.index.field import FieldIndex from zope.index.field import FieldIndex
from zope.interface import implements from zope.interface import implementer
from zope.intid.interfaces import IIntIds from zope.intid.interfaces import IIntIds
from cybertools.link.interfaces import ILinkManager, ILink from cybertools.link.interfaces import ILinkManager, ILink
@implementer(ILinkManager)
class LinkManager(Persistent): class LinkManager(Persistent):
""" A manager (storage, registry) for link objects. """ A manager (storage, registry) for link objects.
""" """
implements(ILinkManager)
uid = int uid = int
# initialization # initialization
@ -127,12 +107,11 @@ class LinkManager(Persistent):
return component.getUtility(IIntIds).getObject(uid) return component.getUtility(IIntIds).getObject(uid)
@implementer(ILink)
class Link(Persistent): class Link(Persistent):
""" A basic link implementation. """ A basic link implementation.
""" """
implements(ILink)
defaults = dict(target=None, defaults = dict(target=None,
linkType=u'link', linkType=u'link',
state=u'valid', state=u'valid',

View file

@ -1,15 +1,15 @@
# cybertools.link.tests
import unittest, doctest import unittest, doctest
from zope.interface.verify import verifyClass from zope.interface.verify import verifyClass
from zope.interface import implements from zope.interface import implementer
from zope.intid.interfaces import IIntIds from zope.intid.interfaces import IIntIds
@implementer(IIntIds)
class IntIdsStub(object): class IntIdsStub(object):
"""A testing stub (mock utility) for IntIds.""" """A testing stub (mock utility) for IntIds."""
implements(IIntIds)
def __init__(self): def __init__(self):
self.objs = [] self.objs = []
@ -29,7 +29,7 @@ class IntIdsStub(object):
self.objs[id] = None self.objs[id] = None
def __iter__(self): def __iter__(self):
return iter(xrange(len(self.objs))) return iter(range(len(self.objs)))
class TestLink(unittest.TestCase): class TestLink(unittest.TestCase):