[Zope-Checkins] SVN: Zope/branches/philikon-aq/lib/python/Products/Five/viewlet/ Freed viewlets from their Acquisition chains

Hanno Schlichting plone at hannosch.info
Sun Jul 29 06:58:03 EDT 2007


Log message for revision 78454:
  Freed viewlets from their Acquisition chains
  

Changed:
  U   Zope/branches/philikon-aq/lib/python/Products/Five/viewlet/README.txt
  U   Zope/branches/philikon-aq/lib/python/Products/Five/viewlet/manager.py
  U   Zope/branches/philikon-aq/lib/python/Products/Five/viewlet/viewlet.py

-=-
Modified: Zope/branches/philikon-aq/lib/python/Products/Five/viewlet/README.txt
===================================================================
--- Zope/branches/philikon-aq/lib/python/Products/Five/viewlet/README.txt	2007-07-29 10:50:15 UTC (rev 78453)
+++ Zope/branches/philikon-aq/lib/python/Products/Five/viewlet/README.txt	2007-07-29 10:58:03 UTC (rev 78454)
@@ -89,8 +89,7 @@
   >>> 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 @@
   ...     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 @@
   >>> 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 @@
 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 @@
 
 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 @@
 
   >>> shownColumns = []
 
-  >>> class ContentsViewletManager(Explicit):
+  >>> class ContentsViewletManager(object):
   ...     zope.interface.implements(interfaces.IViewletManager)
   ...     index = None
   ...
@@ -562,7 +561,7 @@
 
 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 @@
 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

Modified: Zope/branches/philikon-aq/lib/python/Products/Five/viewlet/manager.py
===================================================================
--- Zope/branches/philikon-aq/lib/python/Products/Five/viewlet/manager.py	2007-07-29 10:50:15 UTC (rev 78453)
+++ Zope/branches/philikon-aq/lib/python/Products/Five/viewlet/manager.py	2007-07-29 10:58:03 UTC (rev 78454)
@@ -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 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):

Modified: Zope/branches/philikon-aq/lib/python/Products/Five/viewlet/viewlet.py
===================================================================
--- Zope/branches/philikon-aq/lib/python/Products/Five/viewlet/viewlet.py	2007-07-29 10:50:15 UTC (rev 78453)
+++ Zope/branches/philikon-aq/lib/python/Products/Five/viewlet/viewlet.py	2007-07-29 10:58:03 UTC (rev 78454)
@@ -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 @@
     return class_
 
 
-class ResourceViewletBase(orig_viewlet.ResourceViewletBase, Explicit):
+class ResourceViewletBase(orig_viewlet.ResourceViewletBase):
     pass
 
 def JavaScriptViewlet(path):



More information about the Zope-Checkins mailing list