Skip to content

Commit

Permalink
Stop mixing in Five.bbb.AcquisitionBBB into browser components.
Browse files Browse the repository at this point in the history
  • Loading branch information
hannosch committed Aug 28, 2016
1 parent cc059e2 commit 86a623e
Show file tree
Hide file tree
Showing 28 changed files with 66 additions and 582 deletions.
2 changes: 2 additions & 0 deletions CHANGES.rst
Expand Up @@ -30,6 +30,8 @@ Features Added
Restructuring
+++++++++++++

- Stop mixing in `Five.bbb.AcquisitionBBB` into browser components.

- Integrate `five.pt` code directly into `Products.PageTemplates`.

- Move `Products.SiteAccess` into ZServer distribution.
Expand Down
2 changes: 1 addition & 1 deletion src/App/FactoryDispatcher.py
Expand Up @@ -90,7 +90,7 @@ def __bobo_traverse__(self, REQUEST, name):
FactoryDispatcher)

product = Product(name)
dispatcher = dispatcher_class(product, self.aq_parent, REQUEST)
dispatcher = dispatcher_class(product, self.__parent__, REQUEST)
return dispatcher.__of__(self)


Expand Down
4 changes: 2 additions & 2 deletions src/App/special_dtml.py
Expand Up @@ -24,7 +24,7 @@
import Zope2

from Shared.DC.Scripts.Bindings import Bindings
from Acquisition import Explicit, aq_inner, aq_parent
from Acquisition import Explicit, aq_inner, aq_parent, aq_acquire
from DocumentTemplate.DT_String import _marker, DTReturn, render_blocks
from DocumentTemplate.DT_Util import TemplateDict, InstanceDict
from AccessControl import getSecurityManager
Expand Down Expand Up @@ -166,7 +166,7 @@ def _exec(self, bound_data, args, kw):
else:
# We're first, so get the REQUEST.
try:
req = self.aq_acquire('REQUEST')
req = aq_acquire(self, 'REQUEST')
if hasattr(req, 'taintWrapper'):
req = req.taintWrapper()
except Exception:
Expand Down
4 changes: 2 additions & 2 deletions src/App/tests/test_ApplicationManager.py
Expand Up @@ -127,7 +127,7 @@ def test___getitem___hit(self):
found = dc['foo']
self.assertTrue(isinstance(found, AltDatabaseManager))
self.assertEqual(found.id, 'foo')
self.assertTrue(found.aq_parent is dc)
self.assertTrue(found.__parent__ is dc)
conn = found._p_jar
self.assertTrue(isinstance(conn, FakeConnection))
self.assertTrue(conn.db() is foo)
Expand All @@ -150,7 +150,7 @@ def test___bobo_traverse___hit_db(self):
found = dc.__bobo_traverse__(None, 'foo')
self.assertTrue(isinstance(found, AltDatabaseManager))
self.assertEqual(found.id, 'foo')
self.assertTrue(found.aq_parent is dc)
self.assertTrue(found.__parent__ is dc)
conn = found._p_jar
self.assertTrue(isinstance(conn, FakeConnection))
self.assertTrue(conn.db() is foo)
Expand Down
6 changes: 3 additions & 3 deletions src/OFS/EtagSupport.py
Expand Up @@ -13,11 +13,11 @@

import time

from Acquisition import aq_acquire
from zExceptions import HTTPPreconditionFailed
from zope.interface import implements
from zope.interface import Interface

from zExceptions import HTTPPreconditionFailed


class EtagBaseInterface(Interface):
"""\
Expand Down Expand Up @@ -108,7 +108,7 @@ def http__processMatchHeaders(self, REQUEST=None):
# Process if-match and if-none-match headers

if REQUEST is None:
REQUEST = self.aq_acquire('REQUEST')
REQUEST = aq_acquire(self, 'REQUEST')

matchlist = self.http__parseMatchList(REQUEST, 'if-match')
nonematch = self.http__parseMatchList(REQUEST, 'if-none-match')
Expand Down
4 changes: 2 additions & 2 deletions src/OFS/ObjectManager.py
Expand Up @@ -33,7 +33,7 @@
from AccessControl.Permissions import ftp_access
from AccessControl import getSecurityManager
from AccessControl.ZopeSecurityPolicy import getRoles
from Acquisition import aq_base, aq_parent
from Acquisition import aq_base, aq_acquire, aq_parent
from Acquisition import Implicit
from App.Common import is_acquired
from App.config import getConfiguration
Expand Down Expand Up @@ -770,7 +770,7 @@ def all_meta_types(self, interfaces=None):
interfaces = self._product_interfaces
elif hasattr(self, 'aq_acquire'):
try:
interfaces = self.aq_acquire('_product_interfaces')
interfaces = aq_acquire(self, '_product_interfaces')
except Exception:
pass

Expand Down
10 changes: 5 additions & 5 deletions src/OFS/tests/testObjectManager.py
Expand Up @@ -6,7 +6,7 @@
from AccessControl.SecurityManager import setSecurityPolicy
from AccessControl.SpecialUsers import emergency_user, nobody, system
from AccessControl.User import User # before SpecialUsers
from Acquisition import Implicit
from Acquisition import aq_self, Implicit
from App.config import getConfiguration
from logging import getLogger
from zExceptions import BadRequest
Expand Down Expand Up @@ -444,8 +444,8 @@ def test___getitem___hit(self):
si1 = SimpleItem('1')
om['1'] = si1
got = om['1']
self.assertTrue(got.aq_self is si1)
self.assertTrue(got.aq_parent is om)
self.assertTrue(aq_self(got) is si1)
self.assertTrue(got.__parent__ is om)

def test_get_miss_wo_default(self):
om = self._makeOne()
Expand All @@ -465,8 +465,8 @@ def test_get_hit(self):
si1 = SimpleItem('1')
om['1'] = si1
got = om.get('1')
self.assertTrue(got.aq_self is si1)
self.assertTrue(got.aq_parent is om)
self.assertTrue(aq_self(got) is si1)
self.assertTrue(got.__parent__ is om)

def test_items(self):
om = self._makeOne()
Expand Down
40 changes: 0 additions & 40 deletions src/Products/Five/bbb.py

This file was deleted.

15 changes: 4 additions & 11 deletions src/Products/Five/browser/__init__.py
Expand Up @@ -14,28 +14,21 @@
"""Provide basic browser functionality
"""

import Acquisition
import zope.publisher.browser
from zope.publisher import browser

from Products.Five.bbb import AcquisitionBBB


class BrowserView(zope.publisher.browser.BrowserView, AcquisitionBBB):
class BrowserView(browser.BrowserView):

# Use an explicit __init__ to work around problems with magically inserted
# super classes when using BrowserView as a base for viewlets.
def __init__(self, context, request):
self.context = context
self.request = request

# 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', Acquisition.aq_inner(self.context))
return getattr(self, '_parent', self.context)

def __setParent(self, parent):
self._parent = parent

aq_parent = __parent__ = property(__getParent, __setParent)
__parent__ = property(__getParent, __setParent)
8 changes: 2 additions & 6 deletions src/Products/Five/browser/pagetemplatefile.py
Expand Up @@ -24,8 +24,6 @@
from Products.PageTemplates.Expressions import SecureModuleImporter
from Products.PageTemplates.Expressions import createTrustedZopeEngine

from Products.Five.bbb import AcquisitionBBB

_engine = createTrustedZopeEngine()


Expand Down Expand Up @@ -107,12 +105,10 @@ def __getitem__(self, name):
return getMultiAdapter((self.ob, self.request), name=name)

# When a view's template is accessed e.g. as template.view, a
# BoundPageTemplate object is returned. For BBB reasons, it needs to
# support the aq_* methods and attributes known from Acquisition. For
# that it also needs to be locatable through __parent__.
# BoundPageTemplate object is returned.


class BoundPageTemplate(AcquisitionBBB):
class BoundPageTemplate(object):
def __init__(self, pt, ob):
object.__setattr__(self, 'im_func', pt)
object.__setattr__(self, 'im_self', ob)
Expand Down
3 changes: 1 addition & 2 deletions src/Products/Five/browser/resource.py
Expand Up @@ -26,7 +26,6 @@
from zope.publisher.interfaces.browser import IBrowserPublisher
from zope.ptresource.ptresource import PageTemplate

from Acquisition import aq_base
from Products.Five.browser import BrowserView


Expand Down Expand Up @@ -175,7 +174,7 @@ def get(self, name, default=_marker):

# We need to propagate security so that restrictedTraverse() will
# work
if hasattr(aq_base(self), '__roles__'):
if hasattr(self, '__roles__'):
resource.__roles__ = self.__roles__

return resource
Expand Down
157 changes: 0 additions & 157 deletions src/Products/Five/browser/tests/aqlegacy.py

This file was deleted.

0 comments on commit 86a623e

Please sign in to comment.