Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Integrate code from and drop dependency on
five.globalrequest
.
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
Showing
9 changed files
with
89 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters