browser: Python3 fixes
This commit is contained in:
parent
98ebc30bd5
commit
ad632e23ee
8 changed files with 37 additions and 148 deletions
|
@ -3,7 +3,7 @@ Browser View Tools
|
||||||
==================
|
==================
|
||||||
|
|
||||||
>>> from zope import component, interface
|
>>> from zope import component, interface
|
||||||
>>> from zope.interface import Interface, implements
|
>>> from zope.interface import Interface, implementer
|
||||||
>>> from zope.publisher.interfaces.browser import IBrowserRequest
|
>>> 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:
|
Let's start with a dummy content object and create a view on it:
|
||||||
|
|
||||||
|
>>> #@implementer(Interface)
|
||||||
>>> class SomeObject(object):
|
>>> class SomeObject(object):
|
||||||
... implements(Interface)
|
... pass
|
||||||
|
>>> SomeObject = implementer(Interface)(SomeObject)
|
||||||
>>> obj = SomeObject()
|
>>> obj = SomeObject()
|
||||||
|
|
||||||
>>> from cybertools.browser.view import GenericView
|
>>> from cybertools.browser.view import GenericView
|
||||||
|
@ -122,7 +124,7 @@ ZPT macros:
|
||||||
>>> len(cssMacros)
|
>>> len(cssMacros)
|
||||||
4
|
4
|
||||||
>>> m1 = cssMacros[0]
|
>>> m1 = cssMacros[0]
|
||||||
>>> print m1.name, m1.media, m1.resourceName
|
>>> print(m1.name, m1.media, m1.resourceName)
|
||||||
css all zope3_tablelayout.css
|
css all zope3_tablelayout.css
|
||||||
|
|
||||||
Calling a macro provided by Controller.macros[] returns the real ZPT macro:
|
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'])
|
>>> len(controller.macros['css'])
|
||||||
5
|
5
|
||||||
>>> m5 = controller.macros['css'][4]
|
>>> m5 = controller.macros['css'][4]
|
||||||
>>> print m5.name, m5.media, m5.resourceName
|
>>> print(m5.name, m5.media, m5.resourceName)
|
||||||
css all node.css
|
css all node.css
|
||||||
|
|
||||||
If an identifier is given (the second parameter) a certain macro is only
|
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
|
>>> from cybertools.browser.form import IFormController, FormController
|
||||||
>>> class MyController(FormController):
|
>>> class MyController(FormController):
|
||||||
... def update(self):
|
... def update(self):
|
||||||
... print 'updating...'
|
... print('updating...')
|
||||||
... return True
|
... return True
|
||||||
|
|
||||||
>>> component.provideAdapter(MyController, (View, IBrowserRequest),
|
>>> component.provideAdapter(MyController, (View, IBrowserRequest),
|
||||||
|
|
|
@ -1,32 +1,13 @@
|
||||||
#
|
# cybertools.browser.configurator
|
||||||
# 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
|
|
||||||
#
|
|
||||||
|
|
||||||
"""
|
""" A view configurator provides configuration data for a view controller.
|
||||||
A view configurator provides configuration data for a view controller.
|
|
||||||
|
|
||||||
$Id$
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from zope import component
|
from zope import component
|
||||||
from zope.annotation.interfaces import IAttributeAnnotatable, IAnnotations
|
from zope.annotation.interfaces import IAttributeAnnotatable, IAnnotations
|
||||||
from zope.annotation.attribute import AttributeAnnotations
|
from zope.annotation.attribute import AttributeAnnotations
|
||||||
from zope.cachedescriptors.property import Lazy
|
from zope.cachedescriptors.property import Lazy
|
||||||
from zope.interface import Interface, Attribute, implements
|
from zope.interface import Interface, Attribute, implementer
|
||||||
|
|
||||||
|
|
||||||
# interfaces
|
# interfaces
|
||||||
|
@ -63,12 +44,11 @@ class IMacroViewProperty(IViewProperty):
|
||||||
|
|
||||||
#default implementations
|
#default implementations
|
||||||
|
|
||||||
|
@implementer(IViewConfigurator)
|
||||||
class ViewConfigurator(object):
|
class ViewConfigurator(object):
|
||||||
""" An base class for adapters that allow the registration of view properties.
|
""" An base class for adapters that allow the registration of view properties.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
implements(IViewConfigurator)
|
|
||||||
|
|
||||||
def __init__(self, context, request):
|
def __init__(self, context, request):
|
||||||
self.context = context
|
self.context = context
|
||||||
self.request = request
|
self.request = request
|
||||||
|
@ -109,10 +89,9 @@ class AnnotationViewConfigurator(ViewConfigurator):
|
||||||
return vp
|
return vp
|
||||||
|
|
||||||
|
|
||||||
|
@implementer(IViewProperty)
|
||||||
class ViewProperty(object):
|
class ViewProperty(object):
|
||||||
|
|
||||||
implements(IViewProperty)
|
|
||||||
|
|
||||||
def __init__(self, context, request):
|
def __init__(self, context, request):
|
||||||
self.context = context
|
self.context = context
|
||||||
self.request = request
|
self.request = request
|
||||||
|
@ -128,10 +107,9 @@ class ViewProperty(object):
|
||||||
self.params = params
|
self.params = params
|
||||||
|
|
||||||
|
|
||||||
|
@implementer(IMacroViewProperty)
|
||||||
class MacroViewProperty(ViewProperty):
|
class MacroViewProperty(ViewProperty):
|
||||||
|
|
||||||
implements(IMacroViewProperty)
|
|
||||||
|
|
||||||
template = None
|
template = None
|
||||||
|
|
||||||
def setParams(self, params):
|
def setParams(self, params):
|
||||||
|
|
|
@ -1,27 +1,10 @@
|
||||||
#
|
# cybertools.browser.controller
|
||||||
# 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
|
|
||||||
#
|
|
||||||
|
|
||||||
"""
|
""" Controller for views, templates, macros.
|
||||||
Controller for views, templates, macros.
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from zope import component
|
from zope import component
|
||||||
from zope.app.pagetemplate import ViewPageTemplateFile
|
from zope.browserpage import ViewPageTemplateFile
|
||||||
from zope.cachedescriptors.property import Lazy
|
from zope.cachedescriptors.property import Lazy
|
||||||
|
|
||||||
from cybertools.browser.configurator import IViewConfigurator, IMacroViewProperty
|
from cybertools.browser.configurator import IViewConfigurator, IMacroViewProperty
|
||||||
|
|
|
@ -1,28 +1,10 @@
|
||||||
#
|
# cybertools.browser.form
|
||||||
# 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
|
|
||||||
#
|
|
||||||
|
|
||||||
"""Form Controller stuff: form processing is the part of the
|
"""Form Controller stuff: form processing is the part of the
|
||||||
model/view/controller pattern that deals withform input.
|
model/view/controller pattern that deals withform input.
|
||||||
|
|
||||||
$Id$
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from zope.interface import Interface, implements
|
from zope.interface import Interface, implementer
|
||||||
|
|
||||||
|
|
||||||
class IFormController(Interface):
|
class IFormController(Interface):
|
||||||
|
@ -34,10 +16,9 @@ class IFormController(Interface):
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
@implementer(IFormController)
|
||||||
class FormController(object):
|
class FormController(object):
|
||||||
|
|
||||||
implements(IFormController)
|
|
||||||
|
|
||||||
def __init__(self, context, request):
|
def __init__(self, context, request):
|
||||||
self.view = self.__parent__ = view = context
|
self.view = self.__parent__ = view = context
|
||||||
self.context = view.context # the controller is adapted to a view
|
self.context = view.context # the controller is adapted to a view
|
||||||
|
|
|
@ -1,31 +1,12 @@
|
||||||
#
|
# cybertools.browser.member
|
||||||
# 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
|
|
||||||
#
|
|
||||||
|
|
||||||
"""
|
""" A member information provider is used to collect user/member/person attributes.
|
||||||
A member information provider is used to collect user/member/person attributes.
|
|
||||||
|
|
||||||
$Id$
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from zope import component
|
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.cachedescriptors.property import Lazy
|
||||||
from zope.interface import Interface, Attribute, implements
|
from zope.interface import Interface, Attribute, implementer
|
||||||
|
|
||||||
from cybertools.util.jeep import Jeep
|
from cybertools.util.jeep import Jeep
|
||||||
|
|
||||||
|
@ -63,10 +44,9 @@ class IMemberProperty(Interface):
|
||||||
|
|
||||||
#default implementation
|
#default implementation
|
||||||
|
|
||||||
|
@implementer(IMemberProperty)
|
||||||
class MemberProperty(object):
|
class MemberProperty(object):
|
||||||
|
|
||||||
implements(IMemberProperty)
|
|
||||||
|
|
||||||
def __init__(self, name, value, title=None, category='default'):
|
def __init__(self, name, value, title=None, category='default'):
|
||||||
self.name = name
|
self.name = name
|
||||||
self.value = value
|
self.value = value
|
||||||
|
@ -74,10 +54,9 @@ class MemberProperty(object):
|
||||||
self.category = category
|
self.category = category
|
||||||
|
|
||||||
|
|
||||||
|
@implementer(IMemberInfoProvider)
|
||||||
class MemberInfoProvider(object):
|
class MemberInfoProvider(object):
|
||||||
|
|
||||||
implements(IMemberInfoProvider)
|
|
||||||
|
|
||||||
defaultData = Jeep((MemberProperty('id', '???', u'ID'),
|
defaultData = Jeep((MemberProperty('id', '???', u'ID'),
|
||||||
MemberProperty('title', u'unknown', u'Title'),
|
MemberProperty('title', u'unknown', u'Title'),
|
||||||
MemberProperty('description', u'',
|
MemberProperty('description', u'',
|
||||||
|
|
|
@ -1,28 +1,9 @@
|
||||||
#
|
# cybertools.browser.renderer
|
||||||
# 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
|
|
||||||
#
|
|
||||||
|
|
||||||
"""
|
""" Use ZPT macros as layout renderers.
|
||||||
Use ZPT macros as layout renderers.
|
|
||||||
|
|
||||||
$Id$
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from zope.app.pagetemplate import ViewPageTemplateFile
|
from zope.browserpage import ViewPageTemplateFile
|
||||||
|
|
||||||
from cybertools.util.cache import cache
|
from cybertools.util.cache import cache
|
||||||
|
|
||||||
|
|
|
@ -1,29 +1,12 @@
|
||||||
#
|
# cybertools.browser.view
|
||||||
# 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
|
|
||||||
#
|
|
||||||
|
|
||||||
"""
|
""" A generic view class.
|
||||||
A generic view class.
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from logging import getLogger
|
from logging import getLogger
|
||||||
from zope.app.pagetemplate import ViewPageTemplateFile
|
from zope.browserpage import ViewPageTemplateFile
|
||||||
from zope.app.security.interfaces import IUnauthenticatedPrincipal
|
from zope.authentication.interfaces import IUnauthenticatedPrincipal
|
||||||
from zope.interface import Interface, implements
|
from zope.interface import Interface, implementer
|
||||||
from zope.cachedescriptors.property import Lazy
|
from zope.cachedescriptors.property import Lazy
|
||||||
from zope import component
|
from zope import component
|
||||||
from zope.event import notify
|
from zope.event import notify
|
||||||
|
@ -42,10 +25,9 @@ class IBodyRenderedEvent(Interface):
|
||||||
""" Is fired when the page body has been rendered. """
|
""" Is fired when the page body has been rendered. """
|
||||||
|
|
||||||
|
|
||||||
|
@implementer(IBodyRenderedEvent)
|
||||||
class BodyRenderedEvent(object):
|
class BodyRenderedEvent(object):
|
||||||
|
|
||||||
implements(IBodyRenderedEvent)
|
|
||||||
|
|
||||||
def __init__(self, context, request):
|
def __init__(self, context, request):
|
||||||
self.context = context
|
self.context = context
|
||||||
self.request = request
|
self.request = request
|
||||||
|
|
|
@ -17,6 +17,9 @@ dependencies = [
|
||||||
"lxml",
|
"lxml",
|
||||||
"persistent",
|
"persistent",
|
||||||
"zope.app.container",
|
"zope.app.container",
|
||||||
|
"zope.app.rotterdam",
|
||||||
|
"zope.app.testing",
|
||||||
|
"zope.authentication",
|
||||||
"zope.browserpage",
|
"zope.browserpage",
|
||||||
"zope.component",
|
"zope.component",
|
||||||
"zope.container",
|
"zope.container",
|
||||||
|
|
Loading…
Add table
Reference in a new issue