Skip to content

Commit

Permalink
Integrate code from and drop dependency on five.globalrequest.
Browse files Browse the repository at this point in the history
Version pins are left in place, so for example the last ZCatalog
release can still be installed, without buildout complaining about
missing version pins.
  • Loading branch information
hannosch committed Apr 26, 2017
1 parent d384381 commit aed9cb4
Show file tree
Hide file tree
Showing 9 changed files with 89 additions and 4 deletions.
2 changes: 2 additions & 0 deletions CHANGES.rst
Expand Up @@ -67,6 +67,8 @@ Features Added
Restructuring
+++++++++++++

- Integrate code from and drop dependency on `five.globalrequest`.

- Remove special handling of redirect and unauthorized exceptions from
the WSGI publisher. These are now always raised as exceptions, to
match the behavior of all other HTTPExceptions.
Expand Down
1 change: 0 additions & 1 deletion buildout.cfg
Expand Up @@ -57,7 +57,6 @@ eggs =
DateTime
DocumentTemplate
ExtensionClass
five.globalrequest
MultiMapping
Persistence
zExceptions
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Expand Up @@ -61,7 +61,6 @@ def _read_file(filename):
'RestrictedPython',
'ZConfig >= 2.9.2',
'ZODB',
'five.globalrequest',
'setuptools',
'six',
'sourcecodegen',
Expand All @@ -81,6 +80,7 @@ def _read_file(filename):
'zope.deferredimport',
'zope.event',
'zope.exceptions',
'zope.globalrequest',
'zope.i18n [zcml]',
'zope.i18nmessageid',
'zope.interface >= 3.8',
Expand Down
1 change: 0 additions & 1 deletion sources.cfg
Expand Up @@ -10,7 +10,6 @@ AuthEncoding = git ${remotes:github}/AuthEncoding pushurl=${remotes:github_push}
DateTime = git ${remotes:github}/DateTime pushurl=${remotes:github_push}/DateTime
DocumentTemplate = git ${remotes:github}/DocumentTemplate pushurl=${remotes:github_push}/DocumentTemplate
ExtensionClass = git ${remotes:github}/ExtensionClass pushurl=${remotes:github_push}/ExtensionClass
five.globalrequest = git ${remotes:github}/five.globalrequest pushurl=${remotes:github_push}/five.globalrequest
MultiMapping = git ${remotes:github}/MultiMapping pushurl=${remotes:github_push}/MultiMapping
Persistence = git ${remotes:github}/Persistence pushurl=${remotes:github_push}/Persistence
RestrictedPython = git ${remotes:github}/RestrictedPython pushurl=${remotes:github_push}/RestrictedPython
Expand Down
1 change: 1 addition & 0 deletions src/ZPublisher/configure.zcml
@@ -1,5 +1,6 @@
<configure xmlns="http://namespaces.zope.org/zope">

<include file="hooks.zcml"/>
<include file="i18n.zcml"/>
<include file="publisher.zcml"/>

Expand Down
22 changes: 22 additions & 0 deletions src/ZPublisher/hooks.py
@@ -0,0 +1,22 @@
##############################################################################
#
# Copyright (c) 2002 Zope Foundation and Contributors.
#
# 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
#
##############################################################################

from zope.globalrequest import setRequest, clearRequest


def set_(event):
setRequest(event.request)


def clear(event):
clearRequest()
11 changes: 11 additions & 0 deletions src/ZPublisher/hooks.zcml
@@ -0,0 +1,11 @@
<configure xmlns="http://namespaces.zope.org/zope">

<subscriber
for="ZPublisher.interfaces.IPubStart"
handler=".hooks.set_" />

<subscriber
for="ZPublisher.interfaces.IPubEnd"
handler=".hooks.clear" />

</configure>
52 changes: 52 additions & 0 deletions src/ZPublisher/tests/test_hooks.py
@@ -0,0 +1,52 @@
##############################################################################
#
# Copyright (c) 2002 Zope Foundation and Contributors.
#
# 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
#
##############################################################################

import unittest


class TestHooks(unittest.TestCase):

def test_set(self):

class FauxRequest(object):
pass

class FauxEvent(object):
request = FauxRequest()

event = FauxEvent()

from ZPublisher.hooks import set_
set_(event)

from zope.globalrequest import getRequest
self.assertEquals(getRequest(), event.request)

def test_clear(self):

class FauxRequest(object):
pass

class FauxEvent(object):
request = FauxRequest()

event = FauxEvent()

from zope.globalrequest import setRequest
setRequest(event.request)

from ZPublisher.hooks import clear
clear(event)

from zope.globalrequest import getRequest
self.assertEquals(getRequest(), None)
1 change: 0 additions & 1 deletion src/Zope2/App/configure.zcml
Expand Up @@ -10,7 +10,6 @@
<include file="traversing.zcml" />
<include package="OFS "/>
<include package="ZPublisher" />
<include package="five.globalrequest"/>

<include package="Products.Five" />
<meta:redefinePermission from="zope2.Public" to="zope.Public" />
Expand Down

0 comments on commit aed9cb4

Please sign in to comment.