some more Python3 fixes
This commit is contained in:
parent
2cbd4c11d3
commit
8a6277fbff
11 changed files with 33 additions and 175 deletions
|
@ -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
|
||||
|
|
23
cybertools/external/dsv.py
vendored
23
cybertools/external/dsv.py
vendored
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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):
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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):
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
--------------------------
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -25,6 +25,7 @@ zope-testrunner --test-path=. \
|
|||
-s cybertools.tracking \
|
||||
-s cybertools.typology \
|
||||
-s cybertools.util \
|
||||
-s cybertools.zutil \
|
||||
$*
|
||||
|
||||
#-s cybertools.view \
|
||||
|
|
Loading…
Add table
Reference in a new issue