diff --git a/cybertools/browser/README.txt b/cybertools/browser/README.txt index 5b5dc74..713199f 100644 --- a/cybertools/browser/README.txt +++ b/cybertools/browser/README.txt @@ -3,7 +3,7 @@ Browser View Tools ================== >>> from zope import component, interface - >>> from zope.interface import Interface, implements + >>> from zope.interface import Interface, implementer >>> from zope.publisher.interfaces.browser import IBrowserRequest @@ -17,8 +17,10 @@ the common and node modules there.) Let's start with a dummy content object and create a view on it: + >>> #@implementer(Interface) >>> class SomeObject(object): - ... implements(Interface) + ... pass + >>> SomeObject = implementer(Interface)(SomeObject) >>> obj = SomeObject() >>> from cybertools.browser.view import GenericView @@ -122,7 +124,7 @@ ZPT macros: >>> len(cssMacros) 4 >>> m1 = cssMacros[0] - >>> print m1.name, m1.media, m1.resourceName + >>> print(m1.name, m1.media, m1.resourceName) css all zope3_tablelayout.css Calling a macro provided by Controller.macros[] returns the real ZPT macro: @@ -138,7 +140,7 @@ The pre-set collection of macros for a certain slot may be extended >>> len(controller.macros['css']) 5 >>> m5 = controller.macros['css'][4] - >>> print m5.name, m5.media, m5.resourceName + >>> print(m5.name, m5.media, m5.resourceName) css all node.css If an identifier is given (the second parameter) a certain macro is only @@ -221,7 +223,7 @@ controller issues a redirect. >>> from cybertools.browser.form import IFormController, FormController >>> class MyController(FormController): ... def update(self): - ... print 'updating...' + ... print('updating...') ... return True >>> component.provideAdapter(MyController, (View, IBrowserRequest), diff --git a/cybertools/browser/configurator.py b/cybertools/browser/configurator.py index b8ab791..0ba30a8 100644 --- a/cybertools/browser/configurator.py +++ b/cybertools/browser/configurator.py @@ -1,32 +1,13 @@ -# -# 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.browser.configurator -""" -A view configurator provides configuration data for a view controller. - -$Id$ +""" A view configurator provides configuration data for a view controller. """ from zope import component from zope.annotation.interfaces import IAttributeAnnotatable, IAnnotations from zope.annotation.attribute import AttributeAnnotations from zope.cachedescriptors.property import Lazy -from zope.interface import Interface, Attribute, implements +from zope.interface import Interface, Attribute, implementer # interfaces @@ -63,12 +44,11 @@ class IMacroViewProperty(IViewProperty): #default implementations +@implementer(IViewConfigurator) class ViewConfigurator(object): """ An base class for adapters that allow the registration of view properties. """ - implements(IViewConfigurator) - def __init__(self, context, request): self.context = context self.request = request @@ -109,10 +89,9 @@ class AnnotationViewConfigurator(ViewConfigurator): return vp +@implementer(IViewProperty) class ViewProperty(object): - implements(IViewProperty) - def __init__(self, context, request): self.context = context self.request = request @@ -128,10 +107,9 @@ class ViewProperty(object): self.params = params +@implementer(IMacroViewProperty) class MacroViewProperty(ViewProperty): - implements(IMacroViewProperty) - template = None def setParams(self, params): diff --git a/cybertools/browser/controller.py b/cybertools/browser/controller.py index e9d4044..a5e396d 100644 --- a/cybertools/browser/controller.py +++ b/cybertools/browser/controller.py @@ -1,27 +1,10 @@ -# -# Copyright (c) 2016 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.browser.controller -""" -Controller for views, templates, macros. +""" Controller for views, templates, macros. """ from zope import component -from zope.app.pagetemplate import ViewPageTemplateFile +from zope.browserpage import ViewPageTemplateFile from zope.cachedescriptors.property import Lazy from cybertools.browser.configurator import IViewConfigurator, IMacroViewProperty diff --git a/cybertools/browser/form.py b/cybertools/browser/form.py index e1450c0..70f90b5 100644 --- a/cybertools/browser/form.py +++ b/cybertools/browser/form.py @@ -1,28 +1,10 @@ -# -# Copyright (c) 2006 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.browser.form """Form Controller stuff: form processing is the part of the model/view/controller pattern that deals withform input. - -$Id$ """ -from zope.interface import Interface, implements +from zope.interface import Interface, implementer class IFormController(Interface): @@ -34,10 +16,9 @@ class IFormController(Interface): """ +@implementer(IFormController) class FormController(object): - implements(IFormController) - def __init__(self, context, request): self.view = self.__parent__ = view = context self.context = view.context # the controller is adapted to a view diff --git a/cybertools/browser/member.py b/cybertools/browser/member.py index ad43487..b5ec360 100644 --- a/cybertools/browser/member.py +++ b/cybertools/browser/member.py @@ -1,31 +1,12 @@ -# -# 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.browser.member -""" -A member information provider is used to collect user/member/person attributes. - -$Id$ +""" A member information provider is used to collect user/member/person attributes. """ from zope import component -from zope.app.security.interfaces import IAuthentication +from zope.authentication.interfaces import IAuthentication from zope.cachedescriptors.property import Lazy -from zope.interface import Interface, Attribute, implements +from zope.interface import Interface, Attribute, implementer from cybertools.util.jeep import Jeep @@ -63,10 +44,9 @@ class IMemberProperty(Interface): #default implementation +@implementer(IMemberProperty) class MemberProperty(object): - implements(IMemberProperty) - def __init__(self, name, value, title=None, category='default'): self.name = name self.value = value @@ -74,10 +54,9 @@ class MemberProperty(object): self.category = category +@implementer(IMemberInfoProvider) class MemberInfoProvider(object): - implements(IMemberInfoProvider) - defaultData = Jeep((MemberProperty('id', '???', u'ID'), MemberProperty('title', u'unknown', u'Title'), MemberProperty('description', u'', diff --git a/cybertools/browser/renderer.py b/cybertools/browser/renderer.py index 3ef8d98..2f85d9f 100644 --- a/cybertools/browser/renderer.py +++ b/cybertools/browser/renderer.py @@ -1,28 +1,9 @@ -# -# 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.browser.renderer -""" -Use ZPT macros as layout renderers. - -$Id$ +""" Use ZPT macros as layout renderers. """ -from zope.app.pagetemplate import ViewPageTemplateFile +from zope.browserpage import ViewPageTemplateFile from cybertools.util.cache import cache diff --git a/cybertools/browser/view.py b/cybertools/browser/view.py index 0ec312c..c116c60 100644 --- a/cybertools/browser/view.py +++ b/cybertools/browser/view.py @@ -1,29 +1,12 @@ -# -# Copyright (c) 2016 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.browser.view -""" -A generic view class. +""" A generic view class. """ from logging import getLogger -from zope.app.pagetemplate import ViewPageTemplateFile -from zope.app.security.interfaces import IUnauthenticatedPrincipal -from zope.interface import Interface, implements +from zope.browserpage import ViewPageTemplateFile +from zope.authentication.interfaces import IUnauthenticatedPrincipal +from zope.interface import Interface, implementer from zope.cachedescriptors.property import Lazy from zope import component from zope.event import notify @@ -42,10 +25,9 @@ class IBodyRenderedEvent(Interface): """ Is fired when the page body has been rendered. """ +@implementer(IBodyRenderedEvent) class BodyRenderedEvent(object): - implements(IBodyRenderedEvent) - def __init__(self, context, request): self.context = context self.request = request diff --git a/pyproject.toml b/pyproject.toml index d65813a..55ecb6e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -17,6 +17,9 @@ dependencies = [ "lxml", "persistent", "zope.app.container", + "zope.app.rotterdam", + "zope.app.testing", + "zope.authentication", "zope.browserpage", "zope.component", "zope.container",