Commit 56366e66 authored by Malthe Borch's avatar Malthe Borch

Revert to the standard Zope 3 provider-expression; this is reasonable and...

Revert to the standard Zope 3 provider-expression; this is reasonable and required after the sane acquisition branch has been merged.
parent e36bd5b3
...@@ -223,6 +223,11 @@ Zope Changes ...@@ -223,6 +223,11 @@ Zope Changes
Bugs Fixed Bugs Fixed
- After the proper introduction of parent-pointers, it's now
wrong to acquisition-wrap content providers. We will now use
the "classic" content provider expression from Zope
3. [malthe]
- Testing.ZopeTestCase: Remove quota argument from DemoStorage calls in - Testing.ZopeTestCase: Remove quota argument from DemoStorage calls in
preparation for ZODB 3.9. preparation for ZODB 3.9.
......
##############################################################################
#
# Copyright (c) 2006 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
"""Provider expression.
"""
import zope.event
import zope.interface
import zope.component
from zope.tales import expressions
from zope.contentprovider import interfaces, tales
from zope.location.interfaces import ILocation
from Acquisition.interfaces import IAcquirer
class Z2ProviderExpression(expressions.StringExpr):
zope.interface.implements(interfaces.ITALESProviderExpression)
# This is mostly a copy of
# zope.contentprovider.tales.TALESProviderExpression's __call__
# method.
def __call__(self, econtext):
name = super(Z2ProviderExpression, self).__call__(econtext)
context = econtext.vars['context']
request = econtext.vars['request']
view = econtext.vars['view']
# Try to look up the provider.
provider = zope.component.queryMultiAdapter(
(context, request, view), interfaces.IContentProvider, name)
# Provide a useful error message, if the provider was not found.
if provider is None:
raise interfaces.ContentProviderLookupError(name)
# add the __name__ attribute if it implements ILocation
if ILocation.providedBy(provider):
provider.__name__ = name
# ATTN: This is where we are different from
# TALESProviderExpression: We support Acquisition wrapping.
if IAcquirer.providedBy(provider):
provider = provider.__of__(context)
# Insert the data gotten from the context
tales.addTALNamespaceData(provider, econtext)
# Stage 1: Do the state update.
zope.event.notify(interfaces.BeforeUpdateEvent(provider, request))
provider.update()
# Stage 2: Render the HTML content.
return provider.render()
...@@ -36,7 +36,7 @@ from MultiMapping import MultiMapping ...@@ -36,7 +36,7 @@ from MultiMapping import MultiMapping
from Acquisition import aq_base from Acquisition import aq_base
from zExceptions import NotFound, Unauthorized from zExceptions import NotFound, Unauthorized
from Products.Five.browser.providerexpression import Z2ProviderExpression from zope.contentprovider.tales import TALESProviderExpression
from Products.PageTemplates import ZRPythonExpr from Products.PageTemplates import ZRPythonExpr
from Products.PageTemplates.DeferExpr import LazyExpr from Products.PageTemplates.DeferExpr import LazyExpr
from Products.PageTemplates.GlobalTranslationService import getGlobalTranslationService from Products.PageTemplates.GlobalTranslationService import getGlobalTranslationService
...@@ -334,7 +334,7 @@ def createZopeEngine(): ...@@ -334,7 +334,7 @@ def createZopeEngine():
e.registerType('not', NotExpr) e.registerType('not', NotExpr)
e.registerType('defer', DeferExpr) e.registerType('defer', DeferExpr)
e.registerType('lazy', LazyExpr) e.registerType('lazy', LazyExpr)
e.registerType('provider', Z2ProviderExpression) e.registerType('provider', TALESProviderExpression)
e.registerBaseName('modules', SecureModuleImporter) e.registerBaseName('modules', SecureModuleImporter)
return e return e
......
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