diff --git a/cybertools/integrator/base.py b/cybertools/integrator/base.py index 98be980..11fac4f 100644 --- a/cybertools/integrator/base.py +++ b/cybertools/integrator/base.py @@ -1,34 +1,15 @@ -# -# 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.util.integrator.base -""" -Base implementation for accessing external content objects. - -$Id$ +""" Base implementation for accessing external content objects. """ import mimetypes import os -from urllib import urlencode +from urllib.parse import urlencode from zope.app.container.contained import Contained from zope.cachedescriptors.property import Lazy from zope import component -from zope.interface import implements +from zope.interface import implementer from cybertools.integrator.interfaces import IContainerFactory from cybertools.integrator.interfaces import IItemFactory, IFileFactory @@ -61,10 +42,9 @@ class ProxyBase(object): return self.address.rsplit(os.path.sep, 1)[-1] +@implementer(IReadContainer) class ReadContainer(ProxyBase, Contained): - implements(IReadContainer) - icon = 'folder' @Lazy @@ -112,18 +92,16 @@ class ReadContainer(ProxyBase, Contained): has_key = __contains__ +@implementer(IItem) class Item(ProxyBase, object): - implements(IItem) - icon = 'item' __parent__ = None +@implementer(IFile) class File(Item): - implements(IFile) - def __init__(self, address, contentType, **kw): super(File, self).__init__(address, **kw) self.contentType = contentType @@ -141,10 +119,9 @@ class File(Item): return (mimeTypes.get(self.contentType) or ['unknown'])[0] +@implementer(IImage) class Image(File): - implements(IImage) - icon = 'image' def getImageSize(self): @@ -174,24 +151,21 @@ class Factory(object): return self.proxyClass(address, **kw) +@implementer(IContainerFactory) class ContainerFactory(Factory): - implements(IContainerFactory) - proxyClass = ReadContainer +@implementer(IItemFactory) class ItemFactory(Factory): - implements(IItemFactory) - proxyClass = Item +@implementer(IFileFactory) class FileFactory(Factory): - implements(IFileFactory) - proxyClass = File # real implementations should also care about images diff --git a/cybertools/integrator/filesystem.py b/cybertools/integrator/filesystem.py index 962300d..33a306f 100644 --- a/cybertools/integrator/filesystem.py +++ b/cybertools/integrator/filesystem.py @@ -1,23 +1,6 @@ -# -# Copyright (c) 2012 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.util.integrator.filesystem -""" -Access to objects in the file system. +""" Access to objects in the file system. """ import os, stat @@ -26,7 +9,7 @@ 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 zope.interface import Attribute from cybertools.integrator.base import ContainerFactory, FileFactory from cybertools.integrator.base import ReadContainer, File, Image diff --git a/cybertools/integrator/filesystem.txt b/cybertools/integrator/filesystem.txt index aa05f6a..655b5cd 100644 --- a/cybertools/integrator/filesystem.txt +++ b/cybertools/integrator/filesystem.txt @@ -4,8 +4,6 @@ Integrating objects from external systems Integration of external sources. - ($Id$) - Getting started =============== @@ -101,7 +99,7 @@ A file object has additional attributes/methods. 'index.html' >>> html.contentType 'text/html' - >>> print html.data + >>> print(html.data.decode('UTF-8')) ... Subdirectory diff --git a/pyproject.toml b/pyproject.toml index f331949..d84f2c6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -18,6 +18,7 @@ dependencies = [ "persistent", "pillow", "zope.app.container", + "zope.app.file", "zope.app.rotterdam", "zope.app.testing", "zope.authentication",