Commit 60f2b77e authored by Hanno Schlichting's avatar Hanno Schlichting

Removed some more references to Acquisition

parent 705edbea
...@@ -17,9 +17,7 @@ $Id$ ...@@ -17,9 +17,7 @@ $Id$
""" """
import zope.app.pagetemplate import zope.app.pagetemplate
from Acquisition import aq_base
from Acquisition import aq_get from Acquisition import aq_get
from Acquisition import aq_parent
from AccessControl import getSecurityManager from AccessControl import getSecurityManager
from Products.PageTemplates.Expressions import SecureModuleImporter from Products.PageTemplates.Expressions import SecureModuleImporter
from Products.PageTemplates.Expressions import createTrustedZopeEngine from Products.PageTemplates.Expressions import createTrustedZopeEngine
......
...@@ -188,18 +188,15 @@ information is used: ...@@ -188,18 +188,15 @@ information is used:
</body> </body>
</html> </html>
Now we test a provider using a PageTemplateFile to render itself. It must Now we test a provider using a PageTemplateFile to render itself:
inherit from an Acquisition base class so that the template can use Zope 2
security mechanisms:
>>> import os, tempfile >>> import os, tempfile
>>> temp_dir = tempfile.mkdtemp() >>> temp_dir = tempfile.mkdtemp()
>>> dynTemplate = os.path.join(temp_dir, 'dynamic_template.pt') >>> dynTemplate = os.path.join(temp_dir, 'dynamic_template.pt')
>>> open(dynTemplate, 'w').write( >>> open(dynTemplate, 'w').write(
... 'A simple template: <tal:simple replace="python:view.my_property" />') ... 'A simple template: <tal:simple replace="python:view.my_property" />')
>>> from Acquisition import Explicit
>>> from Products.Five.browser.pagetemplatefile import ZopeTwoPageTemplateFile >>> from Products.Five.browser.pagetemplatefile import ZopeTwoPageTemplateFile
>>> class TemplateProvider(Explicit): >>> class TemplateProvider(object):
... zope.component.adapts(zope.interface.Interface, ... zope.component.adapts(zope.interface.Interface,
... browser.IDefaultBrowserLayer, ... browser.IDefaultBrowserLayer,
... zope.interface.Interface) ... zope.interface.Interface)
......
...@@ -36,7 +36,7 @@ def findSite(obj, iface=ISite): ...@@ -36,7 +36,7 @@ def findSite(obj, iface=ISite):
"""Find a site by walking up the object hierarchy, supporting both """Find a site by walking up the object hierarchy, supporting both
the ``ILocation`` API and Zope 2 Acquisition.""" the ``ILocation`` API and Zope 2 Acquisition."""
while obj is not None and not iface.providedBy(obj): while obj is not None and not iface.providedBy(obj):
obj = getattr(obj, '__parent__', aq_parent(aq_inner(obj))) obj = aq_parent(aq_inner(obj))
return obj return obj
@zope.component.adapter(zope.interface.Interface) @zope.component.adapter(zope.interface.Interface)
......
...@@ -271,13 +271,6 @@ view class are: ...@@ -271,13 +271,6 @@ view class are:
* They need to be initialized with the Zope 2 security system, as * They need to be initialized with the Zope 2 security system, as
otherwise you cannot use the view. otherwise you cannot use the view.
* This also means they need to be part of the Zope 2 acquisition
system, as this is a requirement for Zope 2 security to
function. The ``BrowserView`` base class, available from
``Products.Five``, already inherits from ``Acquisition.Explicit`` to
make this be the case. Acquisition is explicit so no attributes can
be acquired by accident.
An example of a simple view:: An example of a simple view::
from Products.Five import BrowserView from Products.Five import BrowserView
......
...@@ -14,11 +14,9 @@ ...@@ -14,11 +14,9 @@
"""Five-compatible version of ObjectWidget """Five-compatible version of ObjectWidget
This is needed because ObjectWidget uses ViewPageTemplateFile whose This is needed because ObjectWidget uses ViewPageTemplateFile whose
macro definition is unfortunately incompatible with macro definition is unfortunately incompatible with ZopeTwoPageTemplateFile.
ZopeTwoPageTemplateFile. So this subclass uses So this subclass uses ZopeTwoPageTemplateFile for the template that renders
ZopeTwoPageTemplateFile for the template that renders the widget's the widget's sub-editform.
sub-editform. Acquisition has to be mixed in to provide the
ZopeTwoPageTemplateFile with the proper acquisition context.
$Id$ $Id$
""" """
......
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