Commit 8d0a884e authored by Hanno Schlichting's avatar Hanno Schlichting

Commit first version of AQBBB

parent 7289f70e
...@@ -19,9 +19,31 @@ from zope.interface import Interface, implements ...@@ -19,9 +19,31 @@ from zope.interface import Interface, implements
from zope.component.interfaces import ComponentLookupError from zope.component.interfaces import ComponentLookupError
from zope.app.publisher.browser import getDefaultViewName from zope.app.publisher.browser import getDefaultViewName
import zExceptions import Acquisition
import Products.Five.security
from Products.Five import fivemethod
class AquisitionBBB(object):
"""Emulate a class implementing Acquisition.interfaces.IAcquirer and
IAcquisitionWrapper.
"""
def __of__(self, context):
# Technically this isn't in line with the way Acquisition's
# __of__ works. With Acquisition, you get a wrapper around
# the original object and only that wrapper's parent is the
# new context.
return self
aq_self = aq_inner = aq_base = property(lambda self: self)
aq_chain = property(Acquisition.aq_chain)
aq_parent = property(Acquisition.aq_parent)
def aq_acquire(self, *args, **kw):
return Acquisition.aq_acquire(self, *args, **kw)
def aq_inContextOf(self, *args, **kw):
return Acquisition.aq_inContextOf(self, *args, **kw)
class IBrowserDefault(Interface): class IBrowserDefault(Interface):
"""Provide a hook for deciding about the default view for an object""" """Provide a hook for deciding about the default view for an object"""
......
...@@ -18,23 +18,16 @@ $Id$ ...@@ -18,23 +18,16 @@ $Id$
import Acquisition import Acquisition
import zope.publisher.browser import zope.publisher.browser
class BrowserView(zope.publisher.browser.BrowserView): from Products.Five.bbb import AquisitionBBB
# BBB for code that expects BrowserView to still inherit from
# Acquisition.Explicit. class BrowserView(zope.publisher.browser.BrowserView, AquisitionBBB):
# Use an explicit __init__ to work around problems with magically inserted # Use an explicit __init__ to work around problems with magically inserted
# super classes when using BrowserView as a base for viewlets. # super classes when using BrowserView as a base for viewlets.
def __init__(self, context, request): def __init__(self, context, request):
zope.publisher.browser.BrowserView.__init__(self, context, request) zope.publisher.browser.BrowserView.__init__(self, context, request)
def __of__(self, context):
# Technically this isn't in line with the way Acquisition's
# __of__ works. With Acquisition, you get a wrapper around
# the original object and only that wrapper's parent is the
# new context.
return self
# Classes which are still based on Acquisition and access # Classes which are still based on Acquisition and access
# self.context in a method need to call aq_inner on it, or get a # self.context in a method need to call aq_inner on it, or get a
# funky aq_chain. We do this here for BBB friendly purposes. # funky aq_chain. We do this here for BBB friendly purposes.
...@@ -46,14 +39,3 @@ class BrowserView(zope.publisher.browser.BrowserView): ...@@ -46,14 +39,3 @@ class BrowserView(zope.publisher.browser.BrowserView):
self._parent = parent self._parent = parent
aq_parent = __parent__ = property(__getParent, __setParent) aq_parent = __parent__ = property(__getParent, __setParent)
# We provide the aq_* properties here for BBB
aq_self = aq_inner = aq_base = property(lambda self: self)
aq_chain = property(Acquisition.aq_chain)
def aq_acquire(self, *args, **kw):
return Acquisition.aq_acquire(self, *args, **kw)
def aq_inContextOf(self, *args, **kw):
return Acquisition.aq_inContextOf(self, *args, **kw)
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