some more Python3 fixes

This commit is contained in:
Helmut Merz 2024-10-01 16:09:46 +02:00
parent 2cbd4c11d3
commit 8a6277fbff
11 changed files with 33 additions and 175 deletions

View file

@ -1,30 +1,10 @@
#
# Copyright (c) 2010 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
#
# cybertools.composer.report.instance
"""
Report instance and related classes.
$Id$
""" Report instance and related classes.
"""
from string import Template
from zope import component
from zope.interface import implements
from zope.publisher.browser import TestRequest
try:
from zope.traversing.browser.absoluteurl import absoluteURL

View file

@ -1,24 +1,6 @@
#
# Copyright (c) 2010 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
#
"""
Base implementation for import adapters.
# cybertools.external.ds
$Id$
""" Base implementation for import adapters.
"""
import csv
@ -26,7 +8,6 @@ from datetime import date, timedelta
from time import strptime
from zope import component
from zope.interface import implements
from zope.cachedescriptors.property import Lazy
from cybertools.external.base import BaseReader

View file

@ -1,25 +1,6 @@
#
# Copyright (c) 2008 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
#
# cybertools.integrator.bscw
"""
Access to objects in a BSCW repository.
$Id$
""" Access to objects in a BSCW repository.
"""
import logging
@ -31,7 +12,6 @@ from zope import component
from zope.app.file.image import getImageInfo
from zope.cachedescriptors.property import Lazy
from zope.contenttype import guess_content_type
from zope.interface import implements, Attribute
from cybertools.integrator.base import ContainerFactory, ItemFactory, FileFactory
from cybertools.integrator.base import ReadContainer, Item, File, Image

View file

@ -1,31 +1,12 @@
#
# Copyright (c) 2007 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
#
# cybertools.scorm.base
"""
Base classes for providing a generic SCORM-compliant API.
$Id$
""" Base classes for providing a generic SCORM-compliant API.
"""
from zope import component
from zope.component import adapts
from zope import interface
from zope.interface import implements
from zope.interface import implementer
from cybertools.scorm.interfaces import IScormAPI
from cybertools.tracking.interfaces import ITrackingStorage
@ -51,12 +32,12 @@ scormChildren = {
@implementer(IScormAPI)
class ScormAPI(object):
""" ScormAPI objects are temporary adapters created by
browser or XML-RPC views.
"""
implements(IScormAPI)
adapts(ITrackingStorage)
def __init__(self, context):

View file

@ -1,25 +1,6 @@
#
# Copyright (c) 2010 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
#
# cybertools.session.memcached
"""
Store session data in memcached.
$Id$
""" Store session data in memcached.
"""
from zope.app.session.interfaces import IClientId, ISession
@ -28,15 +9,14 @@ from zope.app.session.interfaces import ISessionPkgData, ISessionData
from zope import component
from zope.component import getUtility, adapts
from zope.component.interfaces import ComponentLookupError
from zope.interface import implements
from zope.interface import implementer
from zope.publisher.interfaces import IRequest
from lovely.memcached.interfaces import IMemcachedClient
@implementer(ISessionDataContainer)
class SessionDataContainer(object):
implements(ISessionDataContainer)
lifetime = 24 * 3600
namespace = 'cybertools.session'
@ -58,9 +38,9 @@ class SessionDataContainer(object):
client.set(newValue, key, lifetime=self.lifetime, ns=self.namespace)
@implementer(ISession)
class Session(object):
implements(ISession)
adapts(IRequest)
packageName = 'cybertools.session.memcached'
@ -80,10 +60,9 @@ class Session(object):
return spd
@implementer(ISessionData)
class SessionData(dict):
implements(ISessionData)
def __init__(self, id, parent):
self.id = id
self.parent = parent
@ -110,9 +89,8 @@ class SessionData(dict):
self.parent[self.id] = self
@implementer(ISessionPkgData)
class SessionPkgData(SessionData):
implements(ISessionPkgData)
def __getitem__(self, key):
return super(SessionPkgData, self).__getitem__(key)

View file

@ -5,7 +5,7 @@
from persistent import Persistent
from zope import component
from zope.interface import implements
from zope.interface import implementer
from zope.component.hooks import getSite
from zope.container.interfaces import IContained
from zope.intid.interfaces import IIntIds
@ -17,10 +17,9 @@ from cybertools.util.adapter import AdapterFactory
storages = AdapterFactory()
@implementer(IContained)
class PersistentObject(Persistent):
implements(IContained)
__parent__ = __name__ = None
def update(self, data):

View file

@ -1,25 +1,6 @@
#
# Copyright (c) 2010 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
#
# cybertools.wiki.generic.mixin
"""
Wiki implementation = mixin classes for Zope2 content objects.
$Id$
""" Wiki implementation = mixin classes for Zope2 content objects.
"""
from BTrees.IOBTree import IOTreeSet
@ -30,7 +11,7 @@ from zope.app.intid.interfaces import IIntIds
from zope.cachedescriptors.property import Lazy
from zope import component
from zope.component import adapts
from zope.interface import implements
from zope.interface import implementer
from cybertools.link.base import Link, LinkManager as BaseLinkManager
from cybertools.link.interfaces import ILinkManager
@ -43,10 +24,9 @@ from cybertools.wiki.base.wiki import WikiPage as BaseWikiPage
from cybertools.wiki.interfaces import IWikiConfigInfo, IWikiPage
@implementer(IWikiConfigInfo)
class PersistentConfigInfo(PersistentMapping):
implements(IWikiConfigInfo)
def set(self, functionality, value):
self[functionality] = value

View file

@ -1,45 +1,25 @@
#
# Copyright (c) 2007 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
#
# cybertools.zutil.jeep
"""
A general purpose (thus 'Jeep') class that provides most of the interfaces
""" A general purpose (thus 'Jeep') class that provides most of the interfaces
of sequences and dictionaries and in addition allows attribute access to
the dictionary entries.
This is the Zope-based persistent variant of the Jeep class.
$Id$
"""
from persistent import Persistent
from persistent.list import PersistentList
from BTrees.OOBTree import OOBTree
from zope.app.container.interfaces import IContainer
from zope.interface import implements
from zope.interface import implementer
_notfound = object()
_nodefault = object()
@implementer(IContainer)
class Jeep(Persistent):
implements(IContainer)
_attributes = ('_sequence', '_mapping')
def __init__(self, seq=[]):
@ -78,7 +58,7 @@ class Jeep(Persistent):
del self._mapping[attr]
def __getitem__(self, key):
if type(key) in (int, long):
if isinstance(key, int):
return getattr(self, self._sequence[key])
value = getattr(self, key, _notfound)
if value is _notfound:
@ -125,7 +105,7 @@ class Jeep(Persistent):
def pop(self, key=-1):
value = self[key]
if type(key) in (int, long):
if isinstance(key, int):
key = self._sequence[key]
delattr(self, key)
return value

View file

@ -76,7 +76,7 @@ More Dictionary Methods
KeyError: 'fourth'
>>> dict(jeep)
{'second': 'new second value', 'third': 'third value', 'first': 'first value'}
{'first': 'first value', 'second': 'new second value', 'third': 'third value'}
More Methods and Operators
--------------------------

View file

@ -2,8 +2,6 @@
Data Caching in the Request
===========================
$Id$
>>> from cybertools.zutil.rcache import rcache, rcacheproperty
>>> class View(object):
@ -13,12 +11,12 @@ $Id$
...
... @rcache
... def calculate(self):
... print 'calculating'
... print('calculating')
... return 42
...
... @rcacheproperty
... def value(self):
... print 'calculating'
... print('calculating')
... return 43
>>> from zope.publisher.browser import TestRequest

View file

@ -25,6 +25,7 @@ zope-testrunner --test-path=. \
-s cybertools.tracking \
-s cybertools.typology \
-s cybertools.util \
-s cybertools.zutil \
$*
#-s cybertools.view \