Commit d6d47585 authored by Hanno Schlichting's avatar Hanno Schlichting

Moved special __parent__ behaviour up to the browserview class, so all classes...

Moved special __parent__ behaviour up to the browserview class, so all classes inheriting from it, gain this special behavior.
parent b87e500e
......@@ -17,7 +17,9 @@ $Id$
"""
import zope.publisher.browser
import Acquisition
from Acquisition import aq_chain
from Acquisition import aq_inner
class BrowserView(zope.publisher.browser.BrowserView):
......@@ -27,6 +29,18 @@ class BrowserView(zope.publisher.browser.BrowserView):
def __of__(self, context):
return self
# XXX Classes which are still based on Acquisition and access
# 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.
def __getParent(self):
return getattr(self, '_parent', aq_inner(self.context))
def __setParent(self, parent):
self._parent = parent
__parent__ = property(__getParent, __setParent)
# We provide the aq_* properties here for BBB
@property
......@@ -41,4 +55,4 @@ class BrowserView(zope.publisher.browser.BrowserView):
@property
def aq_chain(self):
return Acquisition.aq_chain(self)
return aq_chain(self)
......@@ -35,7 +35,6 @@ from zope.app.container.interfaces import IContainerNamesContainer
from zope.app.container.constraints import checkFactory, checkObject
from zope.app.publisher.browser.menu import getMenu
from Acquisition import aq_inner
from zExceptions import BadRequest
from OFS.SimpleItem import SimpleItem
......@@ -206,16 +205,6 @@ class ContentAdding(Adding, SimpleItem):
menu_id = "add_content"
def __getParent(self):
# This class is based on Acquisition and accesses self.context
# We need to call aq_inner on it, or we get a funky aq_chain
return getattr(self, '_parent', aq_inner(self.context))
def __setParent(self, parent):
self._parent = parent
__parent__ = property(__getParent, __setParent)
class ObjectManagerNameChooser:
"""A name chooser for a Zope object manager.
"""
......
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