Commit 705edbea authored by Hanno Schlichting's avatar Hanno Schlichting

Freed viewlets from their Acquisition chains

parent 223b6c6e
......@@ -89,8 +89,7 @@ But now we register some viewlets for the manager
>>> from zope.publisher.interfaces.browser import IDefaultBrowserLayer
>>> from zope.publisher.interfaces.browser import IBrowserView
>>> from Acquisition import Explicit
>>> class WeatherBox(Explicit):
>>> class WeatherBox(object):
... zope.interface.implements(interfaces.IViewlet)
...
... def __init__(self, context, request, view, manager):
......@@ -109,7 +108,7 @@ But now we register some viewlets for the manager
... IBrowserView, ILeftColumn),
... interfaces.IViewlet, name='weather')
>>> class SportBox(Explicit):
>>> class SportBox(object):
... zope.interface.implements(interfaces.IViewlet)
...
... def __init__(self, context, request, view, manager):
......@@ -311,7 +310,7 @@ The same is true if the specified attribute does not exist:
>>> foo.render()
Traceback (most recent call last):
...
AttributeError: bar
AttributeError: 'FooViewlet' object has no attribute 'bar'
To create simple template-based viewlets you can use the
``SimpleViewletClass()`` function. This function is very similar to its view
......@@ -365,7 +364,7 @@ fully demonstrate the functionality of the base classes as well.
The viewlet will look up the resource it was given and tries to produce the
absolute URL for it:
>>> class JSResource(Explicit):
>>> class JSResource(object):
... def __init__(self, request):
... self.request = request
...
......@@ -381,7 +380,7 @@ absolute URL for it:
The same works for the CSS resource viewlet:
>>> class CSSResource(Explicit):
>>> class CSSResource(object):
... def __init__(self, request):
... self.request = request
...
......@@ -487,7 +486,7 @@ different item:
>>> shownColumns = []
>>> class ContentsViewletManager(Explicit):
>>> class ContentsViewletManager(object):
... zope.interface.implements(interfaces.IViewletManager)
... index = None
...
......@@ -562,7 +561,7 @@ The Viewlets and the Final Result
Now let's create a first viewlet for the manager...
>>> class NameViewlet(Explicit):
>>> class NameViewlet(object):
...
... def __init__(self, context, request, view, manager):
... self.__parent__ = view
......@@ -635,7 +634,7 @@ that we want to see the name as a column in the table:
Let's now write a second viewlet that will display the size of the object for
us:
>>> class SizeViewlet(Explicit):
>>> class SizeViewlet(object):
...
... def __init__(self, context, request, view, manager):
... self.__parent__ = view
......
......@@ -15,7 +15,7 @@
$Id$
"""
import Acquisition
from Acquisition import aq_base
from AccessControl.ZopeGuards import guarded_hasattr
import zope.interface
import zope.security
......@@ -24,9 +24,7 @@ from zope.viewlet.manager import ViewletManagerBase as origManagerBase
from Products.Five.browser.pagetemplatefile import ZopeTwoPageTemplateFile
aq_base = Acquisition.aq_base
class ViewletManagerBase(origManagerBase, Acquisition.Explicit):
class ViewletManagerBase(origManagerBase):
"""A base class for Viewlet managers to work in Zope2"""
def __getitem__(self, name):
......
......@@ -16,16 +16,14 @@
$Id$
"""
import os
from Acquisition import Explicit
from zope.viewlet import viewlet as orig_viewlet
from Products.Five.browser.pagetemplatefile import ZopeTwoPageTemplateFile
# We add Acquisition to all the base classes to enable security machinery
class ViewletBase(orig_viewlet.ViewletBase, Explicit):
class ViewletBase(orig_viewlet.ViewletBase):
pass
class SimpleAttributeViewlet(orig_viewlet.SimpleAttributeViewlet, Explicit):
class SimpleAttributeViewlet(orig_viewlet.SimpleAttributeViewlet):
pass
class simple(orig_viewlet.simple):
......@@ -52,7 +50,7 @@ def SimpleViewletClass(template, bases=(), attributes=None,
return class_
class ResourceViewletBase(orig_viewlet.ResourceViewletBase, Explicit):
class ResourceViewletBase(orig_viewlet.ResourceViewletBase):
pass
def JavaScriptViewlet(path):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment