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 @@
|
||||||
#
|
# cybertools.composer.report.instance
|
||||||
# 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
|
|
||||||
#
|
|
||||||
|
|
||||||
"""
|
""" Report instance and related classes.
|
||||||
Report instance and related classes.
|
|
||||||
|
|
||||||
$Id$
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from string import Template
|
from string import Template
|
||||||
from zope import component
|
from zope import component
|
||||||
from zope.interface import implements
|
|
||||||
from zope.publisher.browser import TestRequest
|
from zope.publisher.browser import TestRequest
|
||||||
try:
|
try:
|
||||||
from zope.traversing.browser.absoluteurl import absoluteURL
|
from zope.traversing.browser.absoluteurl import absoluteURL
|
||||||
|
|
23
cybertools/external/dsv.py
vendored
23
cybertools/external/dsv.py
vendored
|
@ -1,24 +1,6 @@
|
||||||
#
|
# cybertools.external.ds
|
||||||
# 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.
|
|
||||||
|
|
||||||
$Id$
|
""" Base implementation for import adapters.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import csv
|
import csv
|
||||||
|
@ -26,7 +8,6 @@ from datetime import date, timedelta
|
||||||
from time import strptime
|
from time import strptime
|
||||||
|
|
||||||
from zope import component
|
from zope import component
|
||||||
from zope.interface import implements
|
|
||||||
from zope.cachedescriptors.property import Lazy
|
from zope.cachedescriptors.property import Lazy
|
||||||
|
|
||||||
from cybertools.external.base import BaseReader
|
from cybertools.external.base import BaseReader
|
||||||
|
|
|
@ -1,25 +1,6 @@
|
||||||
#
|
# cybertools.integrator.bscw
|
||||||
# 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
|
|
||||||
#
|
|
||||||
|
|
||||||
"""
|
""" Access to objects in a BSCW repository.
|
||||||
Access to objects in a BSCW repository.
|
|
||||||
|
|
||||||
$Id$
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
@ -31,7 +12,6 @@ from zope import component
|
||||||
from zope.app.file.image import getImageInfo
|
from zope.app.file.image import getImageInfo
|
||||||
from zope.cachedescriptors.property import Lazy
|
from zope.cachedescriptors.property import Lazy
|
||||||
from zope.contenttype import guess_content_type
|
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 ContainerFactory, ItemFactory, FileFactory
|
||||||
from cybertools.integrator.base import ReadContainer, Item, File, Image
|
from cybertools.integrator.base import ReadContainer, Item, File, Image
|
||||||
|
|
|
@ -1,31 +1,12 @@
|
||||||
#
|
# cybertools.scorm.base
|
||||||
# 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
|
|
||||||
#
|
|
||||||
|
|
||||||
"""
|
""" Base classes for providing a generic SCORM-compliant API.
|
||||||
Base classes for providing a generic SCORM-compliant API.
|
|
||||||
|
|
||||||
$Id$
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from zope import component
|
from zope import component
|
||||||
from zope.component import adapts
|
from zope.component import adapts
|
||||||
from zope import interface
|
from zope import interface
|
||||||
from zope.interface import implements
|
from zope.interface import implementer
|
||||||
|
|
||||||
from cybertools.scorm.interfaces import IScormAPI
|
from cybertools.scorm.interfaces import IScormAPI
|
||||||
from cybertools.tracking.interfaces import ITrackingStorage
|
from cybertools.tracking.interfaces import ITrackingStorage
|
||||||
|
@ -51,12 +32,12 @@ scormChildren = {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@implementer(IScormAPI)
|
||||||
class ScormAPI(object):
|
class ScormAPI(object):
|
||||||
""" ScormAPI objects are temporary adapters created by
|
""" ScormAPI objects are temporary adapters created by
|
||||||
browser or XML-RPC views.
|
browser or XML-RPC views.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
implements(IScormAPI)
|
|
||||||
adapts(ITrackingStorage)
|
adapts(ITrackingStorage)
|
||||||
|
|
||||||
def __init__(self, context):
|
def __init__(self, context):
|
||||||
|
|
|
@ -1,25 +1,6 @@
|
||||||
#
|
# cybertools.session.memcached
|
||||||
# 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
|
|
||||||
#
|
|
||||||
|
|
||||||
"""
|
""" Store session data in memcached.
|
||||||
Store session data in memcached.
|
|
||||||
|
|
||||||
$Id$
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from zope.app.session.interfaces import IClientId, ISession
|
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 import component
|
||||||
from zope.component import getUtility, adapts
|
from zope.component import getUtility, adapts
|
||||||
from zope.component.interfaces import ComponentLookupError
|
from zope.component.interfaces import ComponentLookupError
|
||||||
from zope.interface import implements
|
from zope.interface import implementer
|
||||||
from zope.publisher.interfaces import IRequest
|
from zope.publisher.interfaces import IRequest
|
||||||
from lovely.memcached.interfaces import IMemcachedClient
|
from lovely.memcached.interfaces import IMemcachedClient
|
||||||
|
|
||||||
|
|
||||||
|
@implementer(ISessionDataContainer)
|
||||||
class SessionDataContainer(object):
|
class SessionDataContainer(object):
|
||||||
|
|
||||||
implements(ISessionDataContainer)
|
|
||||||
|
|
||||||
lifetime = 24 * 3600
|
lifetime = 24 * 3600
|
||||||
namespace = 'cybertools.session'
|
namespace = 'cybertools.session'
|
||||||
|
|
||||||
|
@ -58,9 +38,9 @@ class SessionDataContainer(object):
|
||||||
client.set(newValue, key, lifetime=self.lifetime, ns=self.namespace)
|
client.set(newValue, key, lifetime=self.lifetime, ns=self.namespace)
|
||||||
|
|
||||||
|
|
||||||
|
@implementer(ISession)
|
||||||
class Session(object):
|
class Session(object):
|
||||||
|
|
||||||
implements(ISession)
|
|
||||||
adapts(IRequest)
|
adapts(IRequest)
|
||||||
|
|
||||||
packageName = 'cybertools.session.memcached'
|
packageName = 'cybertools.session.memcached'
|
||||||
|
@ -80,10 +60,9 @@ class Session(object):
|
||||||
return spd
|
return spd
|
||||||
|
|
||||||
|
|
||||||
|
@implementer(ISessionData)
|
||||||
class SessionData(dict):
|
class SessionData(dict):
|
||||||
|
|
||||||
implements(ISessionData)
|
|
||||||
|
|
||||||
def __init__(self, id, parent):
|
def __init__(self, id, parent):
|
||||||
self.id = id
|
self.id = id
|
||||||
self.parent = parent
|
self.parent = parent
|
||||||
|
@ -110,9 +89,8 @@ class SessionData(dict):
|
||||||
self.parent[self.id] = self
|
self.parent[self.id] = self
|
||||||
|
|
||||||
|
|
||||||
|
@implementer(ISessionPkgData)
|
||||||
class SessionPkgData(SessionData):
|
class SessionPkgData(SessionData):
|
||||||
|
|
||||||
implements(ISessionPkgData)
|
|
||||||
|
|
||||||
def __getitem__(self, key):
|
def __getitem__(self, key):
|
||||||
return super(SessionPkgData, self).__getitem__(key)
|
return super(SessionPkgData, self).__getitem__(key)
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
|
|
||||||
from persistent import Persistent
|
from persistent import Persistent
|
||||||
from zope import component
|
from zope import component
|
||||||
from zope.interface import implements
|
from zope.interface import implementer
|
||||||
from zope.component.hooks import getSite
|
from zope.component.hooks import getSite
|
||||||
from zope.container.interfaces import IContained
|
from zope.container.interfaces import IContained
|
||||||
from zope.intid.interfaces import IIntIds
|
from zope.intid.interfaces import IIntIds
|
||||||
|
@ -17,10 +17,9 @@ from cybertools.util.adapter import AdapterFactory
|
||||||
storages = AdapterFactory()
|
storages = AdapterFactory()
|
||||||
|
|
||||||
|
|
||||||
|
@implementer(IContained)
|
||||||
class PersistentObject(Persistent):
|
class PersistentObject(Persistent):
|
||||||
|
|
||||||
implements(IContained)
|
|
||||||
|
|
||||||
__parent__ = __name__ = None
|
__parent__ = __name__ = None
|
||||||
|
|
||||||
def update(self, data):
|
def update(self, data):
|
||||||
|
|
|
@ -1,25 +1,6 @@
|
||||||
#
|
# cybertools.wiki.generic.mixin
|
||||||
# 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
|
|
||||||
#
|
|
||||||
|
|
||||||
"""
|
""" Wiki implementation = mixin classes for Zope2 content objects.
|
||||||
Wiki implementation = mixin classes for Zope2 content objects.
|
|
||||||
|
|
||||||
$Id$
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from BTrees.IOBTree import IOTreeSet
|
from BTrees.IOBTree import IOTreeSet
|
||||||
|
@ -30,7 +11,7 @@ from zope.app.intid.interfaces import IIntIds
|
||||||
from zope.cachedescriptors.property import Lazy
|
from zope.cachedescriptors.property import Lazy
|
||||||
from zope import component
|
from zope import component
|
||||||
from zope.component import adapts
|
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.base import Link, LinkManager as BaseLinkManager
|
||||||
from cybertools.link.interfaces import ILinkManager
|
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
|
from cybertools.wiki.interfaces import IWikiConfigInfo, IWikiPage
|
||||||
|
|
||||||
|
|
||||||
|
@implementer(IWikiConfigInfo)
|
||||||
class PersistentConfigInfo(PersistentMapping):
|
class PersistentConfigInfo(PersistentMapping):
|
||||||
|
|
||||||
implements(IWikiConfigInfo)
|
|
||||||
|
|
||||||
def set(self, functionality, value):
|
def set(self, functionality, value):
|
||||||
self[functionality] = value
|
self[functionality] = value
|
||||||
|
|
||||||
|
|
|
@ -1,45 +1,25 @@
|
||||||
#
|
# cybertools.zutil.jeep
|
||||||
# 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
|
|
||||||
#
|
|
||||||
|
|
||||||
"""
|
""" 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
|
of sequences and dictionaries and in addition allows attribute access to
|
||||||
the dictionary entries.
|
the dictionary entries.
|
||||||
|
|
||||||
This is the Zope-based persistent variant of the Jeep class.
|
This is the Zope-based persistent variant of the Jeep class.
|
||||||
|
|
||||||
$Id$
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from persistent import Persistent
|
from persistent import Persistent
|
||||||
from persistent.list import PersistentList
|
from persistent.list import PersistentList
|
||||||
from BTrees.OOBTree import OOBTree
|
from BTrees.OOBTree import OOBTree
|
||||||
from zope.app.container.interfaces import IContainer
|
from zope.app.container.interfaces import IContainer
|
||||||
from zope.interface import implements
|
from zope.interface import implementer
|
||||||
|
|
||||||
_notfound = object()
|
_notfound = object()
|
||||||
_nodefault = object()
|
_nodefault = object()
|
||||||
|
|
||||||
|
|
||||||
|
@implementer(IContainer)
|
||||||
class Jeep(Persistent):
|
class Jeep(Persistent):
|
||||||
|
|
||||||
implements(IContainer)
|
|
||||||
|
|
||||||
_attributes = ('_sequence', '_mapping')
|
_attributes = ('_sequence', '_mapping')
|
||||||
|
|
||||||
def __init__(self, seq=[]):
|
def __init__(self, seq=[]):
|
||||||
|
@ -78,7 +58,7 @@ class Jeep(Persistent):
|
||||||
del self._mapping[attr]
|
del self._mapping[attr]
|
||||||
|
|
||||||
def __getitem__(self, key):
|
def __getitem__(self, key):
|
||||||
if type(key) in (int, long):
|
if isinstance(key, int):
|
||||||
return getattr(self, self._sequence[key])
|
return getattr(self, self._sequence[key])
|
||||||
value = getattr(self, key, _notfound)
|
value = getattr(self, key, _notfound)
|
||||||
if value is _notfound:
|
if value is _notfound:
|
||||||
|
@ -125,7 +105,7 @@ class Jeep(Persistent):
|
||||||
|
|
||||||
def pop(self, key=-1):
|
def pop(self, key=-1):
|
||||||
value = self[key]
|
value = self[key]
|
||||||
if type(key) in (int, long):
|
if isinstance(key, int):
|
||||||
key = self._sequence[key]
|
key = self._sequence[key]
|
||||||
delattr(self, key)
|
delattr(self, key)
|
||||||
return value
|
return value
|
||||||
|
|
|
@ -76,7 +76,7 @@ More Dictionary Methods
|
||||||
KeyError: 'fourth'
|
KeyError: 'fourth'
|
||||||
|
|
||||||
>>> dict(jeep)
|
>>> 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
|
More Methods and Operators
|
||||||
--------------------------
|
--------------------------
|
||||||
|
|
|
@ -2,8 +2,6 @@
|
||||||
Data Caching in the Request
|
Data Caching in the Request
|
||||||
===========================
|
===========================
|
||||||
|
|
||||||
$Id$
|
|
||||||
|
|
||||||
>>> from cybertools.zutil.rcache import rcache, rcacheproperty
|
>>> from cybertools.zutil.rcache import rcache, rcacheproperty
|
||||||
|
|
||||||
>>> class View(object):
|
>>> class View(object):
|
||||||
|
@ -13,12 +11,12 @@ $Id$
|
||||||
...
|
...
|
||||||
... @rcache
|
... @rcache
|
||||||
... def calculate(self):
|
... def calculate(self):
|
||||||
... print 'calculating'
|
... print('calculating')
|
||||||
... return 42
|
... return 42
|
||||||
...
|
...
|
||||||
... @rcacheproperty
|
... @rcacheproperty
|
||||||
... def value(self):
|
... def value(self):
|
||||||
... print 'calculating'
|
... print('calculating')
|
||||||
... return 43
|
... return 43
|
||||||
|
|
||||||
>>> from zope.publisher.browser import TestRequest
|
>>> from zope.publisher.browser import TestRequest
|
||||||
|
|
|
@ -25,6 +25,7 @@ zope-testrunner --test-path=. \
|
||||||
-s cybertools.tracking \
|
-s cybertools.tracking \
|
||||||
-s cybertools.typology \
|
-s cybertools.typology \
|
||||||
-s cybertools.util \
|
-s cybertools.util \
|
||||||
|
-s cybertools.zutil \
|
||||||
$*
|
$*
|
||||||
|
|
||||||
#-s cybertools.view \
|
#-s cybertools.view \
|
||||||
|
|
Loading…
Add table
Reference in a new issue