Skip to content

Commit

Permalink
[fc] Repository: plone.subrequest
Browse files Browse the repository at this point in the history
Branch: refs/heads/master
Date: 2015-03-05T17:27:41+01:00
Author: Asko Soukka (datakurre) <asko.soukka@iki.fi>
Commit: https://github.com/plone/plone.subrequest/commit/161041e7b0b5aa2403d22ea7fff63fb3fd1639a4

Fix issue where new cookies from the main request.response are not passed to subrequests.

Files changed:
M plone/subrequest/__init__.py
M plone/subrequest/tests.py

diff --git a/plone/subrequest/__init__.py b/plone/subrequest/__init__.py
index c9d4453..4fe947d 100644
--- a/plone/subrequest/__init__.py
+++ b/plone/subrequest/__init__.py
@@ -95,6 +95,8 @@ def subrequest(url, root=None, stdout=None):
         if name in OTHER_IGNORE or OTHER_IGNORE_RE.match(name) or name.startswith('_'):
             continue
         request.other[name] = parent_value
+    for key, value in parent_request.response.cookies.items():
+        request.cookies[key] = value['value']
     request['PARENT_REQUEST'] = parent_request
     alsoProvides(request, ISubRequest)
     try:
diff --git a/plone/subrequest/tests.py b/plone/subrequest/tests.py
index a7d7c1d..c5f9d8b 100644
--- a/plone/subrequest/tests.py
+++ b/plone/subrequest/tests.py
@@ -152,6 +152,12 @@ def test_parameter(self):
         self.assertTrue('foo' in response.body)
 
     def test_cookies(self):
+        request = getRequest()
+        request.response.setCookie('cookie_name', 'cookie_value')
+        response = subrequest('/folder1/@@parameter')
+        self.assertTrue("'cookie_name'" in response.body)
+
+    def test_subrequest_cookies(self):
         response = subrequest('/folder1/@@test?url=/folder1/cookie')
         self.assertTrue('cookie_name' in response.cookies)
 


Repository: plone.subrequest
Branch: refs/heads/master
Date: 2015-03-05T17:27:41+01:00
Author: Asko Soukka (datakurre) <asko.soukka@iki.fi>
Commit: https://github.com/plone/plone.subrequest/commit/9ca8b8e99cd4c52dbec8f2fd0bfa161729cdf8ef

Update changelog

Files changed:
M CHANGES.txt

diff --git a/CHANGES.txt b/CHANGES.txt
index ee2204c..e45e81c 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,6 +1,13 @@
 Changelog
 =========
 
+1.6.9 (unreleased)
+------------------
+
+- Fix issue where new cookies from the main request.response are not passed to
+  subrequests.
+  [datakurre]
+
 1.6.8 (unreleased)
 ------------------
 


Repository: plone.subrequest
Branch: refs/heads/master
Date: 2015-03-05T17:27:41+01:00
Author: Asko Soukka (datakurre) <asko.soukka@iki.fi>
Commit: https://github.com/plone/plone.subrequest/commit/9161b1d804a3933f0a18d38b9ebe469ec1d4a386

Update changelog

Files changed:
M CHANGES.txt

diff --git a/CHANGES.txt b/CHANGES.txt
index e45e81c..29d8f74 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -8,9 +8,6 @@ Changelog
   subrequests.
   [datakurre]
 
-1.6.8 (unreleased)
-------------------
-
 - Handle sub-requests which contain a doubled // in the path.
   [gweis]
 


Repository: plone.subrequest
Branch: refs/heads/master
Date: 2015-03-05T17:27:41+01:00
Author: Asko Soukka (datakurre) <asko.soukka@iki.fi>
Commit: https://github.com/plone/plone.subrequest/commit/1263a402e411789f296adbd17758af4a719f4e8a

Fix the next version in changelog

Files changed:
M CHANGES.txt

diff --git a/CHANGES.txt b/CHANGES.txt
index 29d8f74..9db44b7 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,7 +1,7 @@
 Changelog
 =========
 
-1.6.9 (unreleased)
+1.6.8 (unreleased)
 ------------------
 
 - Fix issue where new cookies from the main request.response are not passed to


Repository: plone.subrequest
Branch: refs/heads/master
Date: 2015-03-05T17:31:13+01:00
Author: Jens W. Klein (jensens) <jk@kleinundpartner.at>
Commit: https://github.com/plone/plone.subrequest/commit/9fe6bd48f1efca3bbb7d1d5610a0d3b4b0a2e422

fix version confusion

Files changed:
M CHANGES.txt
M setup.py

diff --git a/CHANGES.txt b/CHANGES.txt
index 9db44b7..7f9ebcb 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,13 +1,15 @@
 Changelog
 =========
 
-1.6.8 (unreleased)
+1.6.9 (unreleased)
 ------------------
 
 - Fix issue where new cookies from the main request.response are not passed to
   subrequests.
   [datakurre]
 
+1.6.8 (2014-03-04)
+------------------
 - Handle sub-requests which contain a doubled // in the path.
   [gweis]
 
diff --git a/setup.py b/setup.py
index eee1369..c98e240 100644
--- a/setup.py
+++ b/setup.py
@@ -1,7 +1,7 @@
 import os.path
 from setuptools import setup, find_packages
 
-version = '1.6.8.dev0'
+version = '1.6.9.dev0'
 
 setup(
     name = 'plone.subrequest',


Repository: plone.subrequest
Branch: refs/heads/master
Date: 2015-03-05T17:32:12+01:00
Author: Jens W. Klein (jensens) <jk@kleinundpartner.at>
Commit: https://github.com/plone/plone.subrequest/commit/bd485843b90f4a3a21c976691be2ea366f4f6559

housekeeping: txt-&gt;rst

Files changed:
A CHANGES.rst
A README.rst
M setup.py
D CHANGES.txt
D README.txt

diff --git a/CHANGES.rst b/CHANGES.rst
new file mode 100644
index 0000000..7f9ebcb
--- /dev/null
+++ b/CHANGES.rst
@@ -0,0 +1,114 @@
+Changelog
+=========
+
+1.6.9 (unreleased)
+------------------
+
+- Fix issue where new cookies from the main request.response are not passed to
+  subrequests.
+  [datakurre]
+
+1.6.8 (2014-03-04)
+------------------
+- Handle sub-requests which contain a doubled // in the path.
+  [gweis]
+
+1.6.7 (2012-10-22)
+------------------
+
+- Ensure correct handling of bare virtual hosting urls.
+  [elro]
+
+1.6.6 (2012-06-29)
+------------------
+
+- Log errors that occur handling a subrequest to help debug plone.app.theming
+  errors including content from a different url
+  [anthonygerrard]
+
+1.6.5 (2012-04-15)
+------------------
+
+- Ensure parent url is a string and not unicode.
+  [davisagli]
+
+1.6.4 - 2012-03-22
+------------------
+
+- Fix problems with double encoding some unicode charse by not copying too
+  many ``other`` variables.
+  [elro]
+
+1.6.3 - 2012-02-12
+------------------
+
+- Copy ``other`` request variables such as ``LANGUAGE`` to subrequest.
+  [elro]
+
+1.6.2 - 2011-07-04
+------------------
+
+- Handle spaces in default documents. http://dev.plone.org/plone/ticket/12278
+
+1.6.1 - 2011-07-04
+------------------
+
+- Move tests to package directory to making testing possible when installed
+  normally.
+
+1.6 - 2011-06-06
+----------------
+
+- Ensure url is a string and not unicode.
+  [elro]
+
+1.6b2 - 2011-05-20
+------------------
+
+- Set PARENT_REQUEST and add ISubRequest interface to subrequests.
+  [elro]
+
+1.6b1 - 2011-02-11
+------------------
+
+- Handle IStreamIterator.
+  [elro]
+
+- Simplify API so ``response.getBody()`` always works.
+  [elro]
+
+1.5 - 2010-11-26
+----------------
+
+- Merge cookies from subrequest response into parent response.
+  [awello]
+
+1.4 - 2010-11-10
+----------------
+
+- First processInput, then traverse (fixes #11254)
+  [awello]
+
+1.3 - 2010-08-24
+----------------
+
+- Fixed bug with virtual hosting and quoted paths.
+  [elro]
+
+1.2 - 2010-08-16
+----------------
+
+- Restore zope.component site after subrequest.
+  [elro]
+
+1.1 - 2010-08-14
+----------------
+
+- Virtual hosting, relative url and error response support.
+  [elro]
+
+1.0 - 2010-07-28
+----------------
+
+- Initial release.
+  [elro]
diff --git a/CHANGES.txt b/CHANGES.txt
deleted file mode 100644
index 7f9ebcb..0000000
--- a/CHANGES.txt
+++ /dev/null
@@ -1,114 +0,0 @@
-Changelog
-=========
-
-1.6.9 (unreleased)
-------------------
-
-- Fix issue where new cookies from the main request.response are not passed to
-  subrequests.
-  [datakurre]
-
-1.6.8 (2014-03-04)
-------------------
-- Handle sub-requests which contain a doubled // in the path.
-  [gweis]
-
-1.6.7 (2012-10-22)
-------------------
-
-- Ensure correct handling of bare virtual hosting urls.
-  [elro]
-
-1.6.6 (2012-06-29)
-------------------
-
-- Log errors that occur handling a subrequest to help debug plone.app.theming
-  errors including content from a different url
-  [anthonygerrard]
-
-1.6.5 (2012-04-15)
-------------------
-
-- Ensure parent url is a string and not unicode.
-  [davisagli]
-
-1.6.4 - 2012-03-22
-------------------
-
-- Fix problems with double encoding some unicode charse by not copying too
-  many ``other`` variables.
-  [elro]
-
-1.6.3 - 2012-02-12
-------------------
-
-- Copy ``other`` request variables such as ``LANGUAGE`` to subrequest.
-  [elro]
-
-1.6.2 - 2011-07-04
-------------------
-
-- Handle spaces in default documents. http://dev.plone.org/plone/ticket/12278
-
-1.6.1 - 2011-07-04
-------------------
-
-- Move tests to package directory to making testing possible when installed
-  normally.
-
-1.6 - 2011-06-06
-----------------
-
-- Ensure url is a string and not unicode.
-  [elro]
-
-1.6b2 - 2011-05-20
-------------------
-
-- Set PARENT_REQUEST and add ISubRequest interface to subrequests.
-  [elro]
-
-1.6b1 - 2011-02-11
-------------------
-
-- Handle IStreamIterator.
-  [elro]
-
-- Simplify API so ``response.getBody()`` always works.
-  [elro]
-
-1.5 - 2010-11-26
-----------------
-
-- Merge cookies from subrequest response into parent response.
-  [awello]
-
-1.4 - 2010-11-10
-----------------
-
-- First processInput, then traverse (fixes #11254)
-  [awello]
-
-1.3 - 2010-08-24
-----------------
-
-- Fixed bug with virtual hosting and quoted paths.
-  [elro]
-
-1.2 - 2010-08-16
-----------------
-
-- Restore zope.component site after subrequest.
-  [elro]
-
-1.1 - 2010-08-14
-----------------
-
-- Virtual hosting, relative url and error response support.
-  [elro]
-
-1.0 - 2010-07-28
-----------------
-
-- Initial release.
-  [elro]
diff --git a/README.rst b/README.rst
new file mode 100644
index 0000000..6441138
--- /dev/null
+++ b/README.rst
@@ -0,0 +1,27 @@
+Overview
+========
+
+plone.subrequest provides a mechanism for issuing subrequests under Zope2.
+
+Installation
+============
+
+Plone 4
+-------
+
+An entry point is provided so no special installation is required past adding
+`plone.subrequest` to your instance's `eggs`.
+
+Zope 2.12 without Plone
+-----------------------
+
+Load this package's ZCML in the usual manner.
+
+Zope 2.10
+---------
+
+You must install ZPublisherEventsBackport_ to use this package with Zope 2.10
+and load both package's ZCML. The tests require Zope 2.12 / Python 2.6 so will
+not run.
+
+.. _ZPublisherEventsBackport: http://pypi.python.org/pypi/ZPublisherEventsBackport
diff --git a/README.txt b/README.txt
deleted file mode 100644
index 6441138..0000000
--- a/README.txt
+++ /dev/null
@@ -1,27 +0,0 @@
-Overview
-========
-
-plone.subrequest provides a mechanism for issuing subrequests under Zope2.
-
-Installation
-============
-
-Plone 4
--------
-
-An entry point is provided so no special installation is required past adding
-`plone.subrequest` to your instance's `eggs`.
-
-Zope 2.12 without Plone
------------------------
-
-Load this package's ZCML in the usual manner.
-
-Zope 2.10
----------
-
-You must install ZPublisherEventsBackport_ to use this package with Zope 2.10
-and load both package's ZCML. The tests require Zope 2.12 / Python 2.6 so will
-not run.
-
-.. _ZPublisherEventsBackport: http://pypi.python.org/pypi/ZPublisherEventsBackport
diff --git a/setup.py b/setup.py
index c98e240..a0ce162 100644
--- a/setup.py
+++ b/setup.py
@@ -7,9 +7,9 @@
     name = 'plone.subrequest',
     version = version,
     description = 'Subrequests for Zope2',
-    long_description=open("README.txt").read() + "\n\n" +
+    long_description=open("README.rst").read() + "\n\n" +
         open(os.path.join('plone', 'subrequest', 'usage.txt')).read() + "\n\n" +
-        open("CHANGES.txt").read(),
+        open("CHANGES.rst").read(),
     classifiers=[
         "Environment :: Web Environment",
         "Framework :: Plone",


Repository: plone.subrequest
Branch: refs/heads/master
Date: 2015-03-05T17:55:59+01:00
Author: Jens W. Klein (jensens) <jk@kleinundpartner.at>
Commit: https://github.com/plone/plone.subrequest/commit/034cd27880cbd705bd54a3534e14d9d6ca26434b

housekeeping

Files changed:
M .gitignore

diff --git a/.gitignore b/.gitignore
index e089dba..1545667 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1,23 @@
+*.EGG
+*.EGG-INFO
+*.egg
+*.egg-info
 *.py?
-plone.subrequest.egg-info/
+*.tmp*
+.*.cfg
+.idea
+/*.egg-info/
+/bin/
+/build/
+/build/
+/develop-eggs/
+/dist/
+/downloads/
+/eggs/
+/extras/
+/html/
+/include/
+/lib/
+/local/
+/parts/
+/var/


Repository: plone.subrequest
Branch: refs/heads/master
Date: 2015-03-05T18:14:49+01:00
Author: Jens W. Klein (jensens) <jk@kleinundpartner.at>
Commit: https://github.com/plone/plone.subrequest/commit/8013724732e784dfa59431b1019e3698e7ce496c

pep8 et al

Files changed:
M buildout.cfg
M plone/__init__.py
M plone/subrequest/__init__.py
M plone/subrequest/subresponse.py
M plone/subrequest/testing.py
M plone/subrequest/tests.py
M setup.py

diff --git a/buildout.cfg b/buildout.cfg
index 6f5e928..a9df8db 100644
--- a/buildout.cfg
+++ b/buildout.cfg
@@ -1,10 +1,10 @@
 [buildout]
-develop = .
 parts = checkdocs test
 versions = versions
-extends = http://dist.plone.org/release/4.0-latest/versions.cfg
-extensions = buildout.dumppickedversions
+extends = 
+    http://dist.plone.org/release/4.3-latest/versions.cfg
 
+develop = .
 [checkdocs]
 recipe = zc.recipe.egg
 eggs = collective.checkdocs
@@ -13,8 +13,10 @@ interpreter = py
 [test]
 recipe = zc.recipe.testrunner
 eggs =
-    plone.subrequest [test]
+    plone.subrequest[test]
 defaults = ['--auto-color', '--auto-progress']
 
 [versions]
-unittest2 = 0.5.1
+zc.buildout =
+setuptools =
+plone.subrequest = >1.6.8
diff --git a/plone/__init__.py b/plone/__init__.py
index f48ad10..68c04af 100644
--- a/plone/__init__.py
+++ b/plone/__init__.py
@@ -1,6 +1,2 @@
-# See http://peak.telecommunity.com/DevCenter/setuptools#namespace-packages
-try:
-    __import__('pkg_resources').declare_namespace(__name__)
-except ImportError:
-    from pkgutil import extend_path
-    __path__ = extend_path(__path__, __name__)
+# -*- coding: utf-8 -*-
+__import__('pkg_resources').declare_namespace(__name__)
diff --git a/plone/subrequest/__init__.py b/plone/subrequest/__init__.py
index 4fe947d..002ad91 100644
--- a/plone/subrequest/__init__.py
+++ b/plone/subrequest/__init__.py
@@ -1,5 +1,4 @@
-import re
-
+# -*- coding: utf-8 -*-
 from AccessControl import getSecurityManager
 from AccessControl.SecurityManagement import setSecurityManager
 from Acquisition import aq_base
@@ -9,18 +8,20 @@
 from ZPublisher.mapply import mapply
 from cStringIO import StringIO
 from logging import getLogger
+from plone.subrequest.interfaces import ISubRequest
+from plone.subrequest.subresponse import SubResponse
 from posixpath import normpath
+from urllib import unquote  # Python2.4 does not have urlparse.unquote
 from urlparse import urlsplit, urljoin
-from urllib import unquote # Python2.4 does not have urlparse.unquote
-from zope.interface import alsoProvides
 from zope.globalrequest import getRequest, setRequest
+from zope.interface import alsoProvides
+import re
+
 try:
     from zope.site.hooks import getSite, setSite
 except ImportError:
     from zope.app.component.hooks import getSite, setSite
 
-from plone.subrequest.subresponse import SubResponse
-from plone.subrequest.interfaces import ISubRequest
 
 __all__ = ['subrequest', 'SubResponse']
 
@@ -31,7 +32,7 @@
     'HTTP_IF_MATCH',
     'HTTP_IF_NONE_MATCH',
     'HTTP_IF_RANGE',
-    'HTTP_RANGE', # Not strictly a conditional header, but scrub it anyway
+    'HTTP_RANGE',  # Not strictly a conditional header, but scrub it anyway
     ]
 
 OTHER_IGNORE = set([
@@ -55,13 +56,15 @@
 
 logger = getLogger("plone.subrequest")
 
+
 def subrequest(url, root=None, stdout=None):
     assert url is not None, "You must pass a url"
     if isinstance(url, unicode):
         url = url.encode('utf-8')
     _, _, path, query, _ = urlsplit(url)
     parent_request = getRequest()
-    assert parent_request is not None, "Unable to get request, perhaps zope.globalrequest is not configured."
+    assert parent_request is not None, \
+        "Unable to get request, perhaps zope.globalrequest is not configured."
     parent_site = getSite()
     security_manager = getSecurityManager()
     parent_app = parent_request.PARENTS[-1]
@@ -71,7 +74,9 @@ def subrequest(url, root=None, stdout=None):
         if vurl_parts is not None:
             # Use the virtual host root
             path_past_root = unquote(vurl_parts[-1])
-            root_path = normpath(parent_request['PATH_INFO']).rstrip('/')[:-len(path_past_root) or None]
+            root_path = normpath(
+                parent_request['PATH_INFO']
+            ).rstrip('/')[:-len(path_past_root) or None]
             if root is None:
                 path = root_path + path
             else:
@@ -92,7 +97,9 @@ def subrequest(url, root=None, stdout=None):
         path = normpath(path)
     request = parent_request.clone()
     for name, parent_value in parent_request.other.items():
-        if name in OTHER_IGNORE or OTHER_IGNORE_RE.match(name) or name.startswith('_'):
+        if name in OTHER_IGNORE \
+           or OTHER_IGNORE_RE.match(name) \
+           or name.startswith('_'):
             continue
         request.other[name] = parent_value
     for key, value in parent_request.response.cookies.items():
@@ -106,9 +113,9 @@ def subrequest(url, root=None, stdout=None):
         request['PARENTS'] = [app]
         response = request.response
         response.__class__ = SubResponse
-        response.stderr = None # only used on retry it seems
+        response.stderr = None  # only used on retry it seems
         if stdout is None:
-            stdout = StringIO() # It might be possible to optimize this
+            stdout = StringIO()  # It might be possible to optimize this
         response.stdout = stdout
         environ = request.environ
         environ['PATH_INFO'] = path
@@ -140,4 +147,3 @@ def subrequest(url, root=None, stdout=None):
         setRequest(parent_request)
         setSite(parent_site)
         setSecurityManager(security_manager)
-
diff --git a/plone/subrequest/subresponse.py b/plone/subrequest/subresponse.py
index 2e89a4f..d8c84a9 100644
--- a/plone/subrequest/subresponse.py
+++ b/plone/subrequest/subresponse.py
@@ -1,3 +1,4 @@
+# -*- coding: utf-8 -*-
 from ZPublisher.HTTPResponse import HTTPResponse
 from ZPublisher.Iterators import IStreamIterator
 try:
@@ -6,6 +7,7 @@
     class BlobStreamIterator:
         pass
 
+
 class SubResponse(HTTPResponse):
 
     def setBody(self, body, title='', is_error=0, **kw):
@@ -14,8 +16,10 @@ def setBody(self, body, title='', is_error=0, **kw):
             return HTTPResponse.setBody(self, body, title, is_error, **kw)
         assert not self._wrote
         if isinstance(body, BlobStreamIterator):
-            body = body.blob # A BlobFile
-        if hasattr(body, 'seek') and hasattr(body, 'read') and hasattr(body, 'close'):
+            body = body.blob  # A BlobFile
+        if hasattr(body, 'seek') \
+           and hasattr(body, 'read') and \
+           hasattr(body, 'close'):
             self.stdout = body
             self._wrote = 1
             return
diff --git a/plone/subrequest/testing.py b/plone/subrequest/testing.py
index 1d2ee64..6a3ba0d 100644
--- a/plone/subrequest/testing.py
+++ b/plone/subrequest/testing.py
@@ -1,9 +1,12 @@
-import OFS.Folder
+# -*- coding: utf-8 -*-
 from Products.Five.browser import BrowserView
 from five.localsitemanager import make_site
 from plone.subrequest import subrequest
-from plone.testing import Layer, z2, zodb, zca
-from zope.globalrequest import getRequest, setRequest
+from plone.testing import Layer
+from plone.testing import z2
+from plone.testing import zca
+from plone.testing import zodb
+from zope.globalrequest import setRequest
 
 
 class CookieView(BrowserView):
@@ -20,7 +23,6 @@ def __init__(self, context, request):
         self.keys = self.request.keys()
 
     def __call__(self):
-        response = self.request.response
         return str(self.keys)
 
 
@@ -91,17 +93,23 @@ def __call__(self):
 def singleton(cls):
     return cls()
 
+
 @singleton
 class PLONE_SUBREQEST_FIXTURE(Layer):
     defaultBases = (z2.STARTUP,)
 
     def setUp(self):
         # Stack a new DemoStorage on top of the one from z2.STARTUP.
-        self['zodbDB'] = zodb.stackDemoStorage(self.get('zodbDB'), name='PloneSubRequestFixture')
+        self['zodbDB'] = zodb.stackDemoStorage(
+            self.get('zodbDB'),
+            name='PloneSubRequestFixture'
+        )
 
         # Create a new global registry
         zca.pushGlobalRegistry()
-        self['configurationContext'] = context = zca.stackConfigurationContext(self.get('configurationContext'))
+        self['configurationContext'] = context = zca.stackConfigurationContext(
+            self.get('configurationContext')
+        )
 
         # Load out ZCML
         from zope.configuration import xmlconfig
@@ -111,7 +119,8 @@ def setUp(self):
         with z2.zopeApp() as app:
             # Enable virtual hosting
             z2.installProduct(app, 'Products.SiteAccess')
-            from Products.SiteAccess.VirtualHostMonster import VirtualHostMonster
+            from Products.SiteAccess.VirtualHostMonster import \
+                VirtualHostMonster
             vhm = VirtualHostMonster()
             app._setObject(vhm.getId(), vhm, suppress_events=True)
             # With suppress_events=False, this is called twice...
@@ -149,6 +158,12 @@ def testTearDown(self):
         setRequest(None)
 
 
-INTEGRATION_TESTING = PloneSubrequestLifecycle(bases=(PLONE_SUBREQEST_FIXTURE,), name="PloneSubrequest:Integration")
-FUNCTIONAL_TESTING = z2.FunctionalTesting(bases=(PLONE_SUBREQEST_FIXTURE,), name="PloneSubrequest:Functional")
+INTEGRATION_TESTING = PloneSubrequestLifecycle(
+    bases=(PLONE_SUBREQEST_FIXTURE,),
+    name="PloneSubrequest:Integration"
+)
+FUNCTIONAL_TESTING = z2.FunctionalTesting(
+    bases=(PLONE_SUBREQEST_FIXTURE,),
+    name="PloneSubrequest:Functional"
+)
 
diff --git a/plone/subrequest/tests.py b/plone/subrequest/tests.py
index c5f9d8b..5ee13aa 100644
--- a/plone/subrequest/tests.py
+++ b/plone/subrequest/tests.py
@@ -1,21 +1,29 @@
+# -*- coding: utf-8 -*-
+from plone.subrequest import subrequest
+from plone.subrequest.testing import FUNCTIONAL_TESTING
+from plone.subrequest.testing import INTEGRATION_TESTING
+from plone.testing import z2
+from zope.globalrequest import getRequest
+from zope.site.hooks import getSite
 import manuel.doctest
 import manuel.testcase
 import manuel.testing
 import unittest2 as unittest
 
-from plone.subrequest import subrequest
-from plone.subrequest.testing import INTEGRATION_TESTING, FUNCTIONAL_TESTING
-from plone.testing import z2
-from zope.globalrequest import getRequest
-from zope.site.hooks import getSite
 
 def traverse(url):
     request = getRequest()
-    traversed = request.traverse(url)
+    request.traverse(url)
     request.processInputs()
     request['PATH_INFO'] = url
     return request
 
+VH_TPL = (
+    "/VirtualHostBase/http/example.org:80/%s/VirtualHostRoot"
+    "/_vh_fizz/_vh_buzz/_vh_fizzbuzz/%s"
+)
+NOHOST_VH_TPL = 'http://nohost' + VH_TPL
+
 
 class FunctionalTests(unittest.TestCase):
     layer = FUNCTIONAL_TESTING
@@ -30,7 +38,7 @@ def test_absolute(self):
     def test_virtual_hosting(self):
         parts = ('folder1', 'folder1A/@@url')
         expect = 'folder1A'
-        url = "http://nohost/VirtualHostBase/http/example.org:80/%s/VirtualHostRoot/_vh_fizz/_vh_buzz/_vh_fizzbuzz/%s" % parts
+        url = NOHOST_VH_TPL % parts
         expect_url = 'http://example.org/fizz/buzz/fizzbuzz/%s' % expect
         self.browser.open(url)
         self.assertEqual(self.browser.contents, expect_url)
@@ -38,7 +46,7 @@ def test_virtual_hosting(self):
     def test_virtual_hosting_relative(self):
         parts = ('folder1', 'folder1A?url=folder1Ai/@@url')
         expect = 'folder1A/folder1Ai'
-        url = "http://nohost/VirtualHostBase/http/example.org:80/%s/VirtualHostRoot/_vh_fizz/_vh_buzz/_vh_fizzbuzz/%s" % parts
+        url = NOHOST_VH_TPL % parts
         expect_url = 'http://example.org/fizz/buzz/fizzbuzz/%s' % expect
         self.browser.open(url)
         self.assertEqual(self.browser.contents, expect_url)
@@ -46,7 +54,7 @@ def test_virtual_hosting_relative(self):
     def test_virtual_hosting_absolute(self):
         parts = ('folder1', 'folder1A?url=/folder1B/@@url')
         expect = 'folder1B'
-        url = "http://nohost/VirtualHostBase/http/example.org:80/%s/VirtualHostRoot/_vh_fizz/_vh_buzz/_vh_fizzbuzz/%s" % parts
+        url = NOHOST_VH_TPL % parts
         expect_url = 'http://example.org/fizz/buzz/fizzbuzz/%s' % expect
         self.browser.open(url)
         self.assertEqual(self.browser.contents, expect_url)
@@ -57,35 +65,56 @@ class IntegrationTests(unittest.TestCase):
 
     def test_absolute(self):
         response = subrequest('/folder1/@@url')
-        self.assertEqual(response.body, 'http://nohost/folder1')
+        self.assertEqual(
+            response.body,
+            'http://nohost/folder1'
+        )
 
     def test_absolute_query(self):
         response = subrequest('/folder1/folder1A?url=/folder2/folder2A/@@url')
-        self.assertEqual(response.body, 'http://nohost/folder2/folder2A')
+        self.assertEqual(
+            response.body,
+            'http://nohost/folder2/folder2A'
+        )
 
     def test_relative(self):
         response = subrequest('/folder1?url=folder1B/@@url')
         # /folder1 resolves to /folder1/@@test
-        self.assertEqual(response.body, 'http://nohost/folder1/folder1B')
+        self.assertEqual(
+            response.body,
+            'http://nohost/folder1/folder1B'
+        )
 
     def test_root(self):
         response = subrequest('/')
-        self.assertEqual(response.body, 'Root: http://nohost')
+        self.assertEqual(
+            response.body,
+            'Root: http://nohost'
+        )
 
     def test_virtual_hosting(self):
-        url = "/VirtualHostBase/http/example.org:80/%s/VirtualHostRoot/_vh_fizz/_vh_buzz/_vh_fizzbuzz/%s" % ('folder1', 'folder1A/@@url')
+        url = VH_TPL % ('folder1', 'folder1A/@@url')
         response = subrequest(url)
-        self.assertEqual(response.body, 'http://example.org/fizz/buzz/fizzbuzz/folder1A')
+        self.assertEqual(
+            response.body,
+            'http://example.org/fizz/buzz/fizzbuzz/folder1A'
+        )
 
     def test_virtual_hosting_unicode(self):
-        url = u"/VirtualHostBase/http/example.org:80/%s/VirtualHostRoot/_vh_fizz/_vh_buzz/_vh_fizzbuzz/%s" % ('folder1', 'folder1A/@@url')
+        url = VH_TPL % ('folder1', 'folder1A/@@url')
         response = subrequest(url)
-        self.assertEqual(response.body, 'http://example.org/fizz/buzz/fizzbuzz/folder1A')
+        self.assertEqual(
+            response.body,
+            'http://example.org/fizz/buzz/fizzbuzz/folder1A'
+        )
 
     def test_virtual_hosting_relative(self):
-        url = "/VirtualHostBase/http/example.org:80/%s/VirtualHostRoot/_vh_fizz/_vh_buzz/_vh_fizzbuzz/%s" % ('folder1', 'folder1A?url=folder1B/@@url')
+        url = VH_TPL % ('folder1', 'folder1A?url=folder1B/@@url')
         response = subrequest(url)
-        self.assertEqual(response.body, 'http://example.org/fizz/buzz/fizzbuzz/folder1B')
+        self.assertEqual(
+            response.body,
+            'http://example.org/fizz/buzz/fizzbuzz/folder1B'
+        )
 
     def test_not_found(self):
         response = subrequest('/notfound')
@@ -93,53 +122,85 @@ def test_not_found(self):
 
     def test_virtual_host_root(self):
         parts = ('folder1', 'folder1A/@@url')
-        url = "/VirtualHostBase/http/example.org:80/%s/VirtualHostRoot/_vh_fizz/_vh_buzz/_vh_fizzbuzz/%s" % parts
+        url = VH_TPL % parts
         traverse(url)
         response = subrequest('/folder1B/@@url')
-        self.assertEqual(response.body, 'http://example.org/fizz/buzz/fizzbuzz/folder1B')
+        self.assertEqual(
+            response.body,
+            'http://example.org/fizz/buzz/fizzbuzz/folder1B'
+        )
 
     def test_virtual_host_root_with_root(self):
         parts = ('folder1', 'folder1A/@@url')
-        url = "/VirtualHostBase/http/example.org:80/%s/VirtualHostRoot/_vh_fizz/_vh_buzz/_vh_fizzbuzz/%s" % parts
+        url = VH_TPL % parts
         traverse(url)
         app = self.layer['app']
         response = subrequest('/folder1Ai/@@url', root=app.folder1.folder1A)
-        self.assertEqual(response.body, 'http://example.org/fizz/buzz/fizzbuzz/folder1A/folder1Ai')
+        self.assertEqual(
+            response.body,
+            'http://example.org/fizz/buzz/fizzbuzz/folder1A/folder1Ai'
+        )
 
     def test_virtual_host_space(self):
         parts = ('folder2', 'folder2A/folder2Ai space/@@url')
-        url = "/VirtualHostBase/http/example.org:80/%s/VirtualHostRoot/%s" % parts
+        url = (
+            "/VirtualHostBase/http/example.org:80/%s/VirtualHostRoot/%s" %
+            parts
+        )
         traverse(url)
         app = self.layer['app']
         response = subrequest('/folder2A/@@url', root=app.folder2)
-        self.assertEqual(response.body, 'http://example.org/folder2A')
+        self.assertEqual(
+            response.body,
+            'http://example.org/folder2A'
+        )
 
     def test_virtual_host_root_at_root(self):
-        url = "/VirtualHostBase/http/example.org:80/folder1/VirtualHostRoot/_vh_fizz/_vh_buzz/_vh_fizzbuzz"
+        url = (
+            "/VirtualHostBase/http/example.org:80/folder1/VirtualHostRoot/"
+            "_vh_fizz/_vh_buzz/_vh_fizzbuzz"
+        )
         traverse(url)
         response = subrequest('/folder1B/@@url')
-        self.assertEqual(response.body, 'http://example.org/fizz/buzz/fizzbuzz/folder1B')
+        self.assertEqual(
+            response.body,
+            'http://example.org/fizz/buzz/fizzbuzz/folder1B'
+        )
 
     def test_virtual_host_root_at_root_trailing(self):
-        url = "/VirtualHostBase/http/example.org:80/folder1/VirtualHostRoot/_vh_fizz/_vh_buzz/_vh_fizzbuzz/"
+        url = (
+            "/VirtualHostBase/http/example.org:80/folder1/VirtualHostRoot/"
+            "_vh_fizz/_vh_buzz/_vh_fizzbuzz/"
+        )
         traverse(url)
         response = subrequest('/folder1B/@@url')
-        self.assertEqual(response.body, 'http://example.org/fizz/buzz/fizzbuzz/folder1B')
+        self.assertEqual(
+            response.body,
+            'http://example.org/fizz/buzz/fizzbuzz/folder1B'
+        )
 
     def test_virtual_host_with_root_double_slash(self):
-        url = "/VirtualHostBase/http/example.org:80/VirtualHostRoot/_vh_fizz/folder1/folder2//folder2A"
+        url = (
+            "/VirtualHostBase/http/example.org:80/VirtualHostRoot/"
+            "_vh_fizz/folder1/folder2//folder2A"
+        )
         traverse(url)
         root = self.layer['app'].folder1
         response = subrequest('/folder1B/@@url', root=root)
-        self.assertEqual(response.body, 'http://example.org/fizz/folder1/folder1B')
+        self.assertEqual(
+            response.body,
+            'http://example.org/fizz/folder1/folder1B'
+        )
 
     def test_subrequest_root(self):
         app = self.layer['app']
         response = subrequest('/folder1Ai/@@url', root=app.folder1.folder1A)
-        self.assertEqual(response.body, 'http://nohost/folder1/folder1A/folder1Ai')
+        self.assertEqual(
+            response.body,
+            'http://nohost/folder1/folder1A/folder1Ai'
+        )
 
     def test_site(self):
-        app = self.layer['app']
         traverse('/folder1')
         site_url1 = getSite().absolute_url()
         response = subrequest('/folder2/@@url')
@@ -204,7 +265,11 @@ def test_suite():
     suite = unittest.defaultTestLoader.loadTestsFromName(__name__)
     m = manuel.doctest.Manuel()
     m += manuel.testcase.MarkerManuel()
-    doctests = manuel.testing.TestSuite(m, 'usage.txt', globs=dict(subrequest=subrequest, traverse=traverse))
+    doctests = manuel.testing.TestSuite(
+        m,
+        'usage.txt',
+        globs=dict(subrequest=subrequest, traverse=traverse)
+    )
     # Set the layer on the manuel doctests for now
     for test in doctests:
         test.layer = INTEGRATION_TESTING
diff --git a/setup.py b/setup.py
index a0ce162..1a06ff4 100644
--- a/setup.py
+++ b/setup.py
@@ -4,9 +4,9 @@
 version = '1.6.9.dev0'
 
 setup(
-    name = 'plone.subrequest',
-    version = version,
-    description = 'Subrequests for Zope2',
+    name='plone.subrequest',
+    version=version,
+    description='Subrequests for Zope2',
     long_description=open("README.rst").read() + "\n\n" +
         open(os.path.join('plone', 'subrequest', 'usage.txt')).read() + "\n\n" +
         open("CHANGES.rst").read(),


Repository: plone.subrequest
Branch: refs/heads/master
Date: 2015-03-05T19:03:55+01:00
Author: Jens W. Klein (jensens) <jk@kleinundpartner.at>
Commit: https://github.com/plone/plone.subrequest/commit/f92904947f358fd12f095b0eb0ca5d27b187afc8

Workaround for broken test because of missing dependency declaration in upstream package, see https://github.com/plone/plone.app.blob/issues/19 for details.

Files changed:
M CHANGES.rst
M setup.py

diff --git a/CHANGES.rst b/CHANGES.rst
index 7f9ebcb..69fe80a 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -4,6 +4,14 @@ Changelog
 1.6.9 (unreleased)
 ------------------
 
+- Workaround for broken test because of missing dependency declaration in 
+  upstream package, see https://github.com/plone/plone.app.blob/issues/19
+  for details.
+  [jensens]
+
+- Housekeeping and code cleanup (pep8, et al).
+  [jensens]
+
 - Fix issue where new cookies from the main request.response are not passed to
   subrequests.
   [datakurre]
diff --git a/setup.py b/setup.py
index 1a06ff4..ee51e16 100644
--- a/setup.py
+++ b/setup.py
@@ -41,6 +41,9 @@
             'manuel',
             'plone.testing [z2]',
             'plone.app.blob',
+
+            # see https://github.com/plone/plone.app.blob/issues/19
+            'Products.MimetypesRegistry',
             ],
         },
     entry_points="""


Repository: plone.subrequest
Branch: refs/heads/master
Date: 2015-03-05T19:21:06+01:00
Author: Jens W. Klein (jensens) <jk@kleinundpartner.at>
Commit: https://github.com/plone/plone.subrequest/commit/0f52a877f0be19fa585d65496db35d4088bbc76c

Merge pull request #2 from plone/mosaicsprint

Fix issue where new cookies from the main request.response are not passed to subrequests

Files changed:
A CHANGES.rst
A README.rst
M .gitignore
M buildout.cfg
M plone/__init__.py
M plone/subrequest/__init__.py
M plone/subrequest/subresponse.py
M plone/subrequest/testing.py
M plone/subrequest/tests.py
M setup.py
D CHANGES.txt
D README.txt

diff --git a/.gitignore b/.gitignore
index e089dba..1545667 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1,23 @@
+*.EGG
+*.EGG-INFO
+*.egg
+*.egg-info
 *.py?
-plone.subrequest.egg-info/
+*.tmp*
+.*.cfg
+.idea
+/*.egg-info/
+/bin/
+/build/
+/build/
+/develop-eggs/
+/dist/
+/downloads/
+/eggs/
+/extras/
+/html/
+/include/
+/lib/
+/local/
+/parts/
+/var/
diff --git a/CHANGES.rst b/CHANGES.rst
new file mode 100644
index 0000000..69fe80a
--- /dev/null
+++ b/CHANGES.rst
@@ -0,0 +1,122 @@
+Changelog
+=========
+
+1.6.9 (unreleased)
+------------------
+
+- Workaround for broken test because of missing dependency declaration in 
+  upstream package, see https://github.com/plone/plone.app.blob/issues/19
+  for details.
+  [jensens]
+
+- Housekeeping and code cleanup (pep8, et al).
+  [jensens]
+
+- Fix issue where new cookies from the main request.response are not passed to
+  subrequests.
+  [datakurre]
+
+1.6.8 (2014-03-04)
+------------------
+- Handle sub-requests which contain a doubled // in the path.
+  [gweis]
+
+1.6.7 (2012-10-22)
+------------------
+
+- Ensure correct handling of bare virtual hosting urls.
+  [elro]
+
+1.6.6 (2012-06-29)
+------------------
+
+- Log errors that occur handling a subrequest to help debug plone.app.theming
+  errors including content from a different url
+  [anthonygerrard]
+
+1.6.5 (2012-04-15)
+------------------
+
+- Ensure parent url is a string and not unicode.
+  [davisagli]
+
+1.6.4 - 2012-03-22
+------------------
+
+- Fix problems with double encoding some unicode charse by not copying too
+  many ``other`` variables.
+  [elro]
+
+1.6.3 - 2012-02-12
+------------------
+
+- Copy ``other`` request variables such as ``LANGUAGE`` to subrequest.
+  [elro]
+
+1.6.2 - 2011-07-04
+------------------
+
+- Handle spaces in default documents. http://dev.plone.org/plone/ticket/12278
+
+1.6.1 - 2011-07-04
+------------------
+
+- Move tests to package directory to making testing possible when installed
+  normally.
+
+1.6 - 2011-06-06
+----------------
+
+- Ensure url is a string and not unicode.
+  [elro]
+
+1.6b2 - 2011-05-20
+------------------
+
+- Set PARENT_REQUEST and add ISubRequest interface to subrequests.
+  [elro]
+
+1.6b1 - 2011-02-11
+------------------
+
+- Handle IStreamIterator.
+  [elro]
+
+- Simplify API so ``response.getBody()`` always works.
+  [elro]
+
+1.5 - 2010-11-26
+----------------
+
+- Merge cookies from subrequest response into parent response.
+  [awello]
+
+1.4 - 2010-11-10
+----------------
+
+- First processInput, then traverse (fixes #11254)
+  [awello]
+
+1.3 - 2010-08-24
+----------------
+
+- Fixed bug with virtual hosting and quoted paths.
+  [elro]
+
+1.2 - 2010-08-16
+----------------
+
+- Restore zope.component site after subrequest.
+  [elro]
+
+1.1 - 2010-08-14
+----------------
+
+- Virtual hosting, relative url and error response support.
+  [elro]
+
+1.0 - 2010-07-28
+----------------
+
+- Initial release.
+  [elro]
diff --git a/CHANGES.txt b/CHANGES.txt
deleted file mode 100644
index ee2204c..0000000
--- a/CHANGES.txt
+++ /dev/null
@@ -1,108 +0,0 @@
-Changelog
-=========
-
-1.6.8 (unreleased)
-------------------
-
-- Handle sub-requests which contain a doubled // in the path.
-  [gweis]
-
-1.6.7 (2012-10-22)
-------------------
-
-- Ensure correct handling of bare virtual hosting urls.
-  [elro]
-
-1.6.6 (2012-06-29)
-------------------
-
-- Log errors that occur handling a subrequest to help debug plone.app.theming
-  errors including content from a different url
-  [anthonygerrard]
-
-1.6.5 (2012-04-15)
-------------------
-
-- Ensure parent url is a string and not unicode.
-  [davisagli]
-
-1.6.4 - 2012-03-22
-------------------
-
-- Fix problems with double encoding some unicode charse by not copying too
-  many ``other`` variables.
-  [elro]
-
-1.6.3 - 2012-02-12
-------------------
-
-- Copy ``other`` request variables such as ``LANGUAGE`` to subrequest.
-  [elro]
-
-1.6.2 - 2011-07-04
-------------------
-
-- Handle spaces in default documents. http://dev.plone.org/plone/ticket/12278
-
-1.6.1 - 2011-07-04
-------------------
-
-- Move tests to package directory to making testing possible when installed
-  normally.
-
-1.6 - 2011-06-06
-----------------
-
-- Ensure url is a string and not unicode.
-  [elro]
-
-1.6b2 - 2011-05-20
-------------------
-
-- Set PARENT_REQUEST and add ISubRequest interface to subrequests.
-  [elro]
-
-1.6b1 - 2011-02-11
-------------------
-
-- Handle IStreamIterator.
-  [elro]
-
-- Simplify API so ``response.getBody()`` always works.
-  [elro]
-
-1.5 - 2010-11-26
-----------------
-
-- Merge cookies from subrequest response into parent response.
-  [awello]
-
-1.4 - 2010-11-10
-----------------
-
-- First processInput, then traverse (fixes #11254)
-  [awello]
-
-1.3 - 2010-08-24
-----------------
-
-- Fixed bug with virtual hosting and quoted paths.
-  [elro]
-
-1.2 - 2010-08-16
-----------------
-
-- Restore zope.component site after subrequest.
-  [elro]
-
-1.1 - 2010-08-14
-----------------
-
-- Virtual hosting, relative url and error response support.
-  [elro]
-
-1.0 - 2010-07-28
-----------------
-
-- Initial release.
-  [elro]
diff --git a/README.rst b/README.rst
new file mode 100644
index 0000000..6441138
--- /dev/null
+++ b/README.rst
@@ -0,0 +1,27 @@
+Overview
+========
+
+plone.subrequest provides a mechanism for issuing subrequests under Zope2.
+
+Installation
+============
+
+Plone 4
+-------
+
+An entry point is provided so no special installation is required past adding
+`plone.subrequest` to your instance's `eggs`.
+
+Zope 2.12 without Plone
+-----------------------
+
+Load this package's ZCML in the usual manner.
+
+Zope 2.10
+---------
+
+You must install ZPublisherEventsBackport_ to use this package with Zope 2.10
+and load both package's ZCML. The tests require Zope 2.12 / Python 2.6 so will
+not run.
+
+.. _ZPublisherEventsBackport: http://pypi.python.org/pypi/ZPublisherEventsBackport
diff --git a/README.txt b/README.txt
deleted file mode 100644
index 6441138..0000000
--- a/README.txt
+++ /dev/null
@@ -1,27 +0,0 @@
-Overview
-========
-
-plone.subrequest provides a mechanism for issuing subrequests under Zope2.
-
-Installation
-============
-
-Plone 4
--------
-
-An entry point is provided so no special installation is required past adding
-`plone.subrequest` to your instance's `eggs`.
-
-Zope 2.12 without Plone
------------------------
-
-Load this package's ZCML in the usual manner.
-
-Zope 2.10
----------
-
-You must install ZPublisherEventsBackport_ to use this package with Zope 2.10
-and load both package's ZCML. The tests require Zope 2.12 / Python 2.6 so will
-not run.
-
-.. _ZPublisherEventsBackport: http://pypi.python.org/pypi/ZPublisherEventsBackport
diff --git a/buildout.cfg b/buildout.cfg
index 6f5e928..a9df8db 100644
--- a/buildout.cfg
+++ b/buildout.cfg
@@ -1,10 +1,10 @@
 [buildout]
-develop = .
 parts = checkdocs test
 versions = versions
-extends = http://dist.plone.org/release/4.0-latest/versions.cfg
-extensions = buildout.dumppickedversions
+extends = 
+    http://dist.plone.org/release/4.3-latest/versions.cfg
 
+develop = .
 [checkdocs]
 recipe = zc.recipe.egg
 eggs = collective.checkdocs
@@ -13,8 +13,10 @@ interpreter = py
 [test]
 recipe = zc.recipe.testrunner
 eggs =
-    plone.subrequest [test]
+    plone.subrequest[test]
 defaults = ['--auto-color', '--auto-progress']
 
 [versions]
-unittest2 = 0.5.1
+zc.buildout =
+setuptools =
+plone.subrequest = >1.6.8
diff --git a/plone/__init__.py b/plone/__init__.py
index f48ad10..68c04af 100644
--- a/plone/__init__.py
+++ b/plone/__init__.py
@@ -1,6 +1,2 @@
-# See http://peak.telecommunity.com/DevCenter/setuptools#namespace-packages
-try:
-    __import__('pkg_resources').declare_namespace(__name__)
-except ImportError:
-    from pkgutil import extend_path
-    __path__ = extend_path(__path__, __name__)
+# -*- coding: utf-8 -*-
+__import__('pkg_resources').declare_namespace(__name__)
diff --git a/plone/subrequest/__init__.py b/plone/subrequest/__init__.py
index c9d4453..002ad91 100644
--- a/plone/subrequest/__init__.py
+++ b/plone/subrequest/__init__.py
@@ -1,5 +1,4 @@
-import re
-
+# -*- coding: utf-8 -*-
 from AccessControl import getSecurityManager
 from AccessControl.SecurityManagement import setSecurityManager
 from Acquisition import aq_base
@@ -9,18 +8,20 @@
 from ZPublisher.mapply import mapply
 from cStringIO import StringIO
 from logging import getLogger
+from plone.subrequest.interfaces import ISubRequest
+from plone.subrequest.subresponse import SubResponse
 from posixpath import normpath
+from urllib import unquote  # Python2.4 does not have urlparse.unquote
 from urlparse import urlsplit, urljoin
-from urllib import unquote # Python2.4 does not have urlparse.unquote
-from zope.interface import alsoProvides
 from zope.globalrequest import getRequest, setRequest
+from zope.interface import alsoProvides
+import re
+
 try:
     from zope.site.hooks import getSite, setSite
 except ImportError:
     from zope.app.component.hooks import getSite, setSite
 
-from plone.subrequest.subresponse import SubResponse
-from plone.subrequest.interfaces import ISubRequest
 
 __all__ = ['subrequest', 'SubResponse']
 
@@ -31,7 +32,7 @@
     'HTTP_IF_MATCH',
     'HTTP_IF_NONE_MATCH',
     'HTTP_IF_RANGE',
-    'HTTP_RANGE', # Not strictly a conditional header, but scrub it anyway
+    'HTTP_RANGE',  # Not strictly a conditional header, but scrub it anyway
     ]
 
 OTHER_IGNORE = set([
@@ -55,13 +56,15 @@
 
 logger = getLogger("plone.subrequest")
 
+
 def subrequest(url, root=None, stdout=None):
     assert url is not None, "You must pass a url"
     if isinstance(url, unicode):
         url = url.encode('utf-8')
     _, _, path, query, _ = urlsplit(url)
     parent_request = getRequest()
-    assert parent_request is not None, "Unable to get request, perhaps zope.globalrequest is not configured."
+    assert parent_request is not None, \
+        "Unable to get request, perhaps zope.globalrequest is not configured."
     parent_site = getSite()
     security_manager = getSecurityManager()
     parent_app = parent_request.PARENTS[-1]
@@ -71,7 +74,9 @@ def subrequest(url, root=None, stdout=None):
         if vurl_parts is not None:
             # Use the virtual host root
             path_past_root = unquote(vurl_parts[-1])
-            root_path = normpath(parent_request['PATH_INFO']).rstrip('/')[:-len(path_past_root) or None]
+            root_path = normpath(
+                parent_request['PATH_INFO']
+            ).rstrip('/')[:-len(path_past_root) or None]
             if root is None:
                 path = root_path + path
             else:
@@ -92,9 +97,13 @@ def subrequest(url, root=None, stdout=None):
         path = normpath(path)
     request = parent_request.clone()
     for name, parent_value in parent_request.other.items():
-        if name in OTHER_IGNORE or OTHER_IGNORE_RE.match(name) or name.startswith('_'):
+        if name in OTHER_IGNORE \
+           or OTHER_IGNORE_RE.match(name) \
+           or name.startswith('_'):
             continue
         request.other[name] = parent_value
+    for key, value in parent_request.response.cookies.items():
+        request.cookies[key] = value['value']
     request['PARENT_REQUEST'] = parent_request
     alsoProvides(request, ISubRequest)
     try:
@@ -104,9 +113,9 @@ def subrequest(url, root=None, stdout=None):
         request['PARENTS'] = [app]
         response = request.response
         response.__class__ = SubResponse
-        response.stderr = None # only used on retry it seems
+        response.stderr = None  # only used on retry it seems
         if stdout is None:
-            stdout = StringIO() # It might be possible to optimize this
+            stdout = StringIO()  # It might be possible to optimize this
         response.stdout = stdout
         environ = request.environ
         environ['PATH_INFO'] = path
@@ -138,4 +147,3 @@ def subrequest(url, root=None, stdout=None):
         setRequest(parent_request)
         setSite(parent_site)
         setSecurityManager(security_manager)
-
diff --git a/plone/subrequest/subresponse.py b/plone/subrequest/subresponse.py
index 2e89a4f..d8c84a9 100644
--- a/plone/subrequest/subresponse.py
+++ b/plone/subrequest/subresponse.py
@@ -1,3 +1,4 @@
+# -*- coding: utf-8 -*-
 from ZPublisher.HTTPResponse import HTTPResponse
 from ZPublisher.Iterators import IStreamIterator
 try:
@@ -6,6 +7,7 @@
     class BlobStreamIterator:
         pass
 
+
 class SubResponse(HTTPResponse):
 
     def setBody(self, body, title='', is_error=0, **kw):
@@ -14,8 +16,10 @@ def setBody(self, body, title='', is_error=0, **kw):
             return HTTPResponse.setBody(self, body, title, is_error, **kw)
         assert not self._wrote
         if isinstance(body, BlobStreamIterator):
-            body = body.blob # A BlobFile
-        if hasattr(body, 'seek') and hasattr(body, 'read') and hasattr(body, 'close'):
+            body = body.blob  # A BlobFile
+        if hasattr(body, 'seek') \
+           and hasattr(body, 'read') and \
+           hasattr(body, 'close'):
             self.stdout = body
             self._wrote = 1
             return
diff --git a/plone/subrequest/testing.py b/plone/subrequest/testing.py
index 1d2ee64..6a3ba0d 100644
--- a/plone/subrequest/testing.py
+++ b/plone/subrequest/testing.py
@@ -1,9 +1,12 @@
-import OFS.Folder
+# -*- coding: utf-8 -*-
 from Products.Five.browser import BrowserView
 from five.localsitemanager import make_site
 from plone.subrequest import subrequest
-from plone.testing import Layer, z2, zodb, zca
-from zope.globalrequest import getRequest, setRequest
+from plone.testing import Layer
+from plone.testing import z2
+from plone.testing import zca
+from plone.testing import zodb
+from zope.globalrequest import setRequest
 
 
 class CookieView(BrowserView):
@@ -20,7 +23,6 @@ def __init__(self, context, request):
         self.keys = self.request.keys()
 
     def __call__(self):
-        response = self.request.response
         return str(self.keys)
 
 
@@ -91,17 +93,23 @@ def __call__(self):
 def singleton(cls):
     return cls()
 
+
 @singleton
 class PLONE_SUBREQEST_FIXTURE(Layer):
     defaultBases = (z2.STARTUP,)
 
     def setUp(self):
         # Stack a new DemoStorage on top of the one from z2.STARTUP.
-        self['zodbDB'] = zodb.stackDemoStorage(self.get('zodbDB'), name='PloneSubRequestFixture')
+        self['zodbDB'] = zodb.stackDemoStorage(
+            self.get('zodbDB'),
+            name='PloneSubRequestFixture'
+        )
 
         # Create a new global registry
         zca.pushGlobalRegistry()
-        self['configurationContext'] = context = zca.stackConfigurationContext(self.get('configurationContext'))
+        self['configurationContext'] = context = zca.stackConfigurationContext(
+            self.get('configurationContext')
+        )
 
         # Load out ZCML
         from zope.configuration import xmlconfig
@@ -111,7 +119,8 @@ def setUp(self):
         with z2.zopeApp() as app:
             # Enable virtual hosting
             z2.installProduct(app, 'Products.SiteAccess')
-            from Products.SiteAccess.VirtualHostMonster import VirtualHostMonster
+            from Products.SiteAccess.VirtualHostMonster import \
+                VirtualHostMonster
             vhm = VirtualHostMonster()
             app._setObject(vhm.getId(), vhm, suppress_events=True)
             # With suppress_events=False, this is called twice...
@@ -149,6 +158,12 @@ def testTearDown(self):
         setRequest(None)
 
 
-INTEGRATION_TESTING = PloneSubrequestLifecycle(bases=(PLONE_SUBREQEST_FIXTURE,), name="PloneSubrequest:Integration")
-FUNCTIONAL_TESTING = z2.FunctionalTesting(bases=(PLONE_SUBREQEST_FIXTURE,), name="PloneSubrequest:Functional")
+INTEGRATION_TESTING = PloneSubrequestLifecycle(
+    bases=(PLONE_SUBREQEST_FIXTURE,),
+    name="PloneSubrequest:Integration"
+)
+FUNCTIONAL_TESTING = z2.FunctionalTesting(
+    bases=(PLONE_SUBREQEST_FIXTURE,),
+    name="PloneSubrequest:Functional"
+)
 
diff --git a/plone/subrequest/tests.py b/plone/subrequest/tests.py
index a7d7c1d..5ee13aa 100644
--- a/plone/subrequest/tests.py
+++ b/plone/subrequest/tests.py
@@ -1,21 +1,29 @@
+# -*- coding: utf-8 -*-
+from plone.subrequest import subrequest
+from plone.subrequest.testing import FUNCTIONAL_TESTING
+from plone.subrequest.testing import INTEGRATION_TESTING
+from plone.testing import z2
+from zope.globalrequest import getRequest
+from zope.site.hooks import getSite
 import manuel.doctest
 import manuel.testcase
 import manuel.testing
 import unittest2 as unittest
 
-from plone.subrequest import subrequest
-from plone.subrequest.testing import INTEGRATION_TESTING, FUNCTIONAL_TESTING
-from plone.testing import z2
-from zope.globalrequest import getRequest
-from zope.site.hooks import getSite
 
 def traverse(url):
     request = getRequest()
-    traversed = request.traverse(url)
+    request.traverse(url)
     request.processInputs()
     request['PATH_INFO'] = url
     return request
 
+VH_TPL = (
+    "/VirtualHostBase/http/example.org:80/%s/VirtualHostRoot"
+    "/_vh_fizz/_vh_buzz/_vh_fizzbuzz/%s"
+)
+NOHOST_VH_TPL = 'http://nohost' + VH_TPL
+
 
 class FunctionalTests(unittest.TestCase):
     layer = FUNCTIONAL_TESTING
@@ -30,7 +38,7 @@ def test_absolute(self):
     def test_virtual_hosting(self):
         parts = ('folder1', 'folder1A/@@url')
         expect = 'folder1A'
-        url = "http://nohost/VirtualHostBase/http/example.org:80/%s/VirtualHostRoot/_vh_fizz/_vh_buzz/_vh_fizzbuzz/%s" % parts
+        url = NOHOST_VH_TPL % parts
         expect_url = 'http://example.org/fizz/buzz/fizzbuzz/%s' % expect
         self.browser.open(url)
         self.assertEqual(self.browser.contents, expect_url)
@@ -38,7 +46,7 @@ def test_virtual_hosting(self):
     def test_virtual_hosting_relative(self):
         parts = ('folder1', 'folder1A?url=folder1Ai/@@url')
         expect = 'folder1A/folder1Ai'
-        url = "http://nohost/VirtualHostBase/http/example.org:80/%s/VirtualHostRoot/_vh_fizz/_vh_buzz/_vh_fizzbuzz/%s" % parts
+        url = NOHOST_VH_TPL % parts
         expect_url = 'http://example.org/fizz/buzz/fizzbuzz/%s' % expect
         self.browser.open(url)
         self.assertEqual(self.browser.contents, expect_url)
@@ -46,7 +54,7 @@ def test_virtual_hosting_relative(self):
     def test_virtual_hosting_absolute(self):
         parts = ('folder1', 'folder1A?url=/folder1B/@@url')
         expect = 'folder1B'
-        url = "http://nohost/VirtualHostBase/http/example.org:80/%s/VirtualHostRoot/_vh_fizz/_vh_buzz/_vh_fizzbuzz/%s" % parts
+        url = NOHOST_VH_TPL % parts
         expect_url = 'http://example.org/fizz/buzz/fizzbuzz/%s' % expect
         self.browser.open(url)
         self.assertEqual(self.browser.contents, expect_url)
@@ -57,35 +65,56 @@ class IntegrationTests(unittest.TestCase):
 
     def test_absolute(self):
         response = subrequest('/folder1/@@url')
-        self.assertEqual(response.body, 'http://nohost/folder1')
+        self.assertEqual(
+            response.body,
+            'http://nohost/folder1'
+        )
 
     def test_absolute_query(self):
         response = subrequest('/folder1/folder1A?url=/folder2/folder2A/@@url')
-        self.assertEqual(response.body, 'http://nohost/folder2/folder2A')
+        self.assertEqual(
+            response.body,
+            'http://nohost/folder2/folder2A'
+        )
 
     def test_relative(self):
         response = subrequest('/folder1?url=folder1B/@@url')
         # /folder1 resolves to /folder1/@@test
-        self.assertEqual(response.body, 'http://nohost/folder1/folder1B')
+        self.assertEqual(
+            response.body,
+            'http://nohost/folder1/folder1B'
+        )
 
     def test_root(self):
         response = subrequest('/')
-        self.assertEqual(response.body, 'Root: http://nohost')
+        self.assertEqual(
+            response.body,
+            'Root: http://nohost'
+        )
 
     def test_virtual_hosting(self):
-        url = "/VirtualHostBase/http/example.org:80/%s/VirtualHostRoot/_vh_fizz/_vh_buzz/_vh_fizzbuzz/%s" % ('folder1', 'folder1A/@@url')
+        url = VH_TPL % ('folder1', 'folder1A/@@url')
         response = subrequest(url)
-        self.assertEqual(response.body, 'http://example.org/fizz/buzz/fizzbuzz/folder1A')
+        self.assertEqual(
+            response.body,
+            'http://example.org/fizz/buzz/fizzbuzz/folder1A'
+        )
 
     def test_virtual_hosting_unicode(self):
-        url = u"/VirtualHostBase/http/example.org:80/%s/VirtualHostRoot/_vh_fizz/_vh_buzz/_vh_fizzbuzz/%s" % ('folder1', 'folder1A/@@url')
+        url = VH_TPL % ('folder1', 'folder1A/@@url')
         response = subrequest(url)
-        self.assertEqual(response.body, 'http://example.org/fizz/buzz/fizzbuzz/folder1A')
+        self.assertEqual(
+            response.body,
+            'http://example.org/fizz/buzz/fizzbuzz/folder1A'
+        )
 
     def test_virtual_hosting_relative(self):
-        url = "/VirtualHostBase/http/example.org:80/%s/VirtualHostRoot/_vh_fizz/_vh_buzz/_vh_fizzbuzz/%s" % ('folder1', 'folder1A?url=folder1B/@@url')
+        url = VH_TPL % ('folder1', 'folder1A?url=folder1B/@@url')
         response = subrequest(url)
-        self.assertEqual(response.body, 'http://example.org/fizz/buzz/fizzbuzz/folder1B')
+        self.assertEqual(
+            response.body,
+            'http://example.org/fizz/buzz/fizzbuzz/folder1B'
+        )
 
     def test_not_found(self):
         response = subrequest('/notfound')
@@ -93,53 +122,85 @@ def test_not_found(self):
 
     def test_virtual_host_root(self):
         parts = ('folder1', 'folder1A/@@url')
-        url = "/VirtualHostBase/http/example.org:80/%s/VirtualHostRoot/_vh_fizz/_vh_buzz/_vh_fizzbuzz/%s" % parts
+        url = VH_TPL % parts
         traverse(url)
         response = subrequest('/folder1B/@@url')
-        self.assertEqual(response.body, 'http://example.org/fizz/buzz/fizzbuzz/folder1B')
+        self.assertEqual(
+            response.body,
+            'http://example.org/fizz/buzz/fizzbuzz/folder1B'
+        )
 
     def test_virtual_host_root_with_root(self):
         parts = ('folder1', 'folder1A/@@url')
-        url = "/VirtualHostBase/http/example.org:80/%s/VirtualHostRoot/_vh_fizz/_vh_buzz/_vh_fizzbuzz/%s" % parts
+        url = VH_TPL % parts
         traverse(url)
         app = self.layer['app']
         response = subrequest('/folder1Ai/@@url', root=app.folder1.folder1A)
-        self.assertEqual(response.body, 'http://example.org/fizz/buzz/fizzbuzz/folder1A/folder1Ai')
+        self.assertEqual(
+            response.body,
+            'http://example.org/fizz/buzz/fizzbuzz/folder1A/folder1Ai'
+        )
 
     def test_virtual_host_space(self):
         parts = ('folder2', 'folder2A/folder2Ai space/@@url')
-        url = "/VirtualHostBase/http/example.org:80/%s/VirtualHostRoot/%s" % parts
+        url = (
+            "/VirtualHostBase/http/example.org:80/%s/VirtualHostRoot/%s" %
+            parts
+        )
         traverse(url)
         app = self.layer['app']
         response = subrequest('/folder2A/@@url', root=app.folder2)
-        self.assertEqual(response.body, 'http://example.org/folder2A')
+        self.assertEqual(
+            response.body,
+            'http://example.org/folder2A'
+        )
 
     def test_virtual_host_root_at_root(self):
-        url = "/VirtualHostBase/http/example.org:80/folder1/VirtualHostRoot/_vh_fizz/_vh_buzz/_vh_fizzbuzz"
+        url = (
+            "/VirtualHostBase/http/example.org:80/folder1/VirtualHostRoot/"
+            "_vh_fizz/_vh_buzz/_vh_fizzbuzz"
+        )
         traverse(url)
         response = subrequest('/folder1B/@@url')
-        self.assertEqual(response.body, 'http://example.org/fizz/buzz/fizzbuzz/folder1B')
+        self.assertEqual(
+            response.body,
+            'http://example.org/fizz/buzz/fizzbuzz/folder1B'
+        )
 
     def test_virtual_host_root_at_root_trailing(self):
-        url = "/VirtualHostBase/http/example.org:80/folder1/VirtualHostRoot/_vh_fizz/_vh_buzz/_vh_fizzbuzz/"
+        url = (
+            "/VirtualHostBase/http/example.org:80/folder1/VirtualHostRoot/"
+            "_vh_fizz/_vh_buzz/_vh_fizzbuzz/"
+        )
         traverse(url)
         response = subrequest('/folder1B/@@url')
-        self.assertEqual(response.body, 'http://example.org/fizz/buzz/fizzbuzz/folder1B')
+        self.assertEqual(
+            response.body,
+            'http://example.org/fizz/buzz/fizzbuzz/folder1B'
+        )
 
     def test_virtual_host_with_root_double_slash(self):
-        url = "/VirtualHostBase/http/example.org:80/VirtualHostRoot/_vh_fizz/folder1/folder2//folder2A"
+        url = (
+            "/VirtualHostBase/http/example.org:80/VirtualHostRoot/"
+            "_vh_fizz/folder1/folder2//folder2A"
+        )
         traverse(url)
         root = self.layer['app'].folder1
         response = subrequest('/folder1B/@@url', root=root)
-        self.assertEqual(response.body, 'http://example.org/fizz/folder1/folder1B')
+        self.assertEqual(
+            response.body,
+            'http://example.org/fizz/folder1/folder1B'
+        )
 
     def test_subrequest_root(self):
         app = self.layer['app']
         response = subrequest('/folder1Ai/@@url', root=app.folder1.folder1A)
-        self.assertEqual(response.body, 'http://nohost/folder1/folder1A/folder1Ai')
+        self.assertEqual(
+            response.body,
+            'http://nohost/folder1/folder1A/folder1Ai'
+        )
 
     def test_site(self):
-        app = self.layer['app']
         traverse('/folder1')
         site_url1 = getSite().absolute_url()
         response = subrequest('/folder2/@@url')
@@ -152,6 +213,12 @@ def test_parameter(self):
         self.assertTrue('foo' in response.body)
 
     def test_cookies(self):
+        request = getRequest()
+        request.response.setCookie('cookie_name', 'cookie_value')
+        response = subrequest('/folder1/@@parameter')
+        self.assertTrue("'cookie_name'" in response.body)
+
+    def test_subrequest_cookies(self):
         response = subrequest('/folder1/@@test?url=/folder1/cookie')
         self.assertTrue('cookie_name' in response.cookies)
 
@@ -198,7 +265,11 @@ def test_suite():
     suite = unittest.defaultTestLoader.loadTestsFromName(__name__)
     m = manuel.doctest.Manuel()
     m += manuel.testcase.MarkerManuel()
-    doctests = manuel.testing.TestSuite(m, 'usage.txt', globs=dict(subrequest=subrequest, traverse=traverse))
+    doctests = manuel.testing.TestSuite(
+        m,
+        'usage.txt',
+        globs=dict(subrequest=subrequest, traverse=traverse)
+    )
     # Set the layer on the manuel doctests for now
     for test in doctests:
         test.layer = INTEGRATION_TESTING
diff --git a/setup.py b/setup.py
index eee1369..ee51e16 100644
--- a/setup.py
+++ b/setup.py
@@ -1,15 +1,15 @@
 import os.path
 from setuptools import setup, find_packages
 
-version = '1.6.8.dev0'
+version = '1.6.9.dev0'
 
 setup(
-    name = 'plone.subrequest',
-    version = version,
-    description = 'Subrequests for Zope2',
-    long_description=open("README.txt").read() + "\n\n" +
+    name='plone.subrequest',
+    version=version,
+    description='Subrequests for Zope2',
+    long_description=open("README.rst").read() + "\n\n" +
         open(os.path.join('plone', 'subrequest', 'usage.txt')).read() + "\n\n" +
-        open("CHANGES.txt").read(),
+        open("CHANGES.rst").read(),
     classifiers=[
         "Environment :: Web Environment",
         "Framework :: Plone",
@@ -41,6 +41,9 @@
             'manuel',
             'plone.testing [z2]',
             'plone.app.blob',
+
+            # see https://github.com/plone/plone.app.blob/issues/19
+            'Products.MimetypesRegistry',
             ],
         },
     entry_points="""
  • Loading branch information
jensens committed Mar 5, 2015
1 parent 3e26f92 commit c42ba3c
Showing 1 changed file with 2,029 additions and 110 deletions.
Loading

0 comments on commit c42ba3c

Please sign in to comment.