[Checkins] SVN: zope.app.http/branches/adamg-3.4.5/ merge r108613 and align them with KGS 3.4-ish packages
Adam Groszer
agroszer at gmail.com
Thu Jan 28 13:15:55 EST 2010
Log message for revision 108617:
merge r108613 and align them with KGS 3.4-ish packages
Changed:
U zope.app.http/branches/adamg-3.4.5/CHANGES.txt
U zope.app.http/branches/adamg-3.4.5/buildout.cfg
U zope.app.http/branches/adamg-3.4.5/setup.py
U zope.app.http/branches/adamg-3.4.5/src/zope/app/http/exception/methodnotallowed.py
U zope.app.http/branches/adamg-3.4.5/src/zope/app/http/exception/tests/test_methodnotallowed.py
-=-
Modified: zope.app.http/branches/adamg-3.4.5/CHANGES.txt
===================================================================
--- zope.app.http/branches/adamg-3.4.5/CHANGES.txt 2010-01-28 16:24:54 UTC (rev 108616)
+++ zope.app.http/branches/adamg-3.4.5/CHANGES.txt 2010-01-28 18:15:55 UTC (rev 108617)
@@ -2,9 +2,17 @@
CHANGES
=======
-3.4.4 (unreleased)
+3.4.5 (2010-01-28)
------------------
+- Backport r108613 from trunk:
+ Fix for an edge case:
+ If someone does a defaultView for the context object and someone comes with
+ a not allowed method, the exception view fails on getAdapters
+
+3.4.4 (2009-01-29)
+------------------
+
- Make tests compatible with new zope.traversing release.
3.4.3 (2009-01-27)
Modified: zope.app.http/branches/adamg-3.4.5/buildout.cfg
===================================================================
--- zope.app.http/branches/adamg-3.4.5/buildout.cfg 2010-01-28 16:24:54 UTC (rev 108616)
+++ zope.app.http/branches/adamg-3.4.5/buildout.cfg 2010-01-28 18:15:55 UTC (rev 108617)
@@ -2,6 +2,14 @@
develop = .
parts = test
+extends = http://download.zope.org/zope3.4/3.4.0/versions.cfg
+
+versions = versions
+
+[versions]
+zope.app.http = 3.4.5dev
+zc.buildout = 1.4.3
+
[test]
recipe = zc.recipe.testrunner
eggs = zope.app.http [test]
Modified: zope.app.http/branches/adamg-3.4.5/setup.py
===================================================================
--- zope.app.http/branches/adamg-3.4.5/setup.py 2010-01-28 16:24:54 UTC (rev 108616)
+++ zope.app.http/branches/adamg-3.4.5/setup.py 2010-01-28 18:15:55 UTC (rev 108617)
@@ -22,7 +22,7 @@
return open(os.path.join(os.path.dirname(__file__), *rnames)).read()
setup(name='zope.app.http',
- version = '3.4.4',
+ version = '3.4.5dev',
author='Zope Corporation and Contributors',
author_email='zope-dev at zope.org',
description='HTTP Behavior for the Zope Publisher',
@@ -47,11 +47,12 @@
packages=find_packages('src'),
package_dir = {'': 'src'},
namespace_packages=['zope', 'zope.app'],
- extras_require=dict(
- test=['zope.app.testing',
- 'zope.app.securitypolicy',
+ extras_require = dict(
+ test = ['zope.app.securitypolicy',
'zope.app.file',
- 'zope.app.zcmlfiles']),
+ 'zope.app.zcmlfiles',
+ 'zope.app.testing',
+ ]),
install_requires=['setuptools',
'zope.interface',
'zope.publisher',
Modified: zope.app.http/branches/adamg-3.4.5/src/zope/app/http/exception/methodnotallowed.py
===================================================================
--- zope.app.http/branches/adamg-3.4.5/src/zope/app/http/exception/methodnotallowed.py 2010-01-28 16:24:54 UTC (rev 108616)
+++ zope.app.http/branches/adamg-3.4.5/src/zope/app/http/exception/methodnotallowed.py 2010-01-28 18:15:55 UTC (rev 108617)
@@ -26,15 +26,22 @@
def __init__(self, error, request):
self.error = error
self.request = request
- self.allow = [
- name for name, adapter
- in getAdapters((error.object, error.request), Interface)
- if hasattr(adapter, name)]
- self.allow.sort()
+ allow = []
+ try:
+ # see test_methodnotallowed.TestMethodNotAllowedView.test_defaultView
+ # I could not solve this with a while ... next() iterator
+ # because it seems like once the generator had an exception it
+ # stops returning items
+ self.allow = [
+ name for name, adapter
+ in getAdapters((error.object, error.request), Interface)
+ if hasattr(adapter, name)]
+ self.allow.sort()
+ except TypeError:
+ self.allow = []
+
def __call__(self):
self.request.response.setHeader('Allow', ', '.join(self.allow))
self.request.response.setStatus(405)
return 'Method Not Allowed'
-
-
Modified: zope.app.http/branches/adamg-3.4.5/src/zope/app/http/exception/tests/test_methodnotallowed.py
===================================================================
--- zope.app.http/branches/adamg-3.4.5/src/zope/app/http/exception/tests/test_methodnotallowed.py 2010-01-28 16:24:54 UTC (rev 108616)
+++ zope.app.http/branches/adamg-3.4.5/src/zope/app/http/exception/tests/test_methodnotallowed.py 2010-01-28 18:15:55 UTC (rev 108617)
@@ -52,12 +52,23 @@
def setUp(self):
from zope.publisher.interfaces.http import IHTTPRequest
+
PlacelessSetup.setUp(self)
ztapi.provideView(I, IHTTPRequest, Interface, 'GET', GetView)
ztapi.provideView(I, IHTTPRequest, Interface, 'DELETE', DeleteView)
ztapi.provideView(I, IHTTPRequest, Interface, 'irrelevant', GetView)
ztapi.provideView(I, IHTTPRequest, Interface, 'also_irr.', DeleteView)
+ from zope.component.interfaces import IDefaultViewName
+ from zope.publisher.interfaces.browser import IBrowserRequest
+ #do the same as defaultView would for something like:
+ #<defaultView
+ # for=".test_methodnotallowed.I"
+ # name="index.html"
+ # />
+
+ ztapi.provideAdapter((I, IBrowserRequest), IDefaultViewName, u'index.html')
+
def test(self):
from zope.app.publication.http import MethodNotAllowed
from zope.app.http.exception.methodnotallowed \
@@ -76,6 +87,34 @@
self.assertEqual(result, 'Method Not Allowed')
+ def test_defaultView(self):
+ # do the same with a BrowserRequest
+ # edge case is that if someone does a defaultView for the context object
+ # but the app is not prepared for webdav or whatever
+ # and someone comes with a not allowed method, the exception
+ # view fails on getAdapters
+ # this might be an issue with zope.publisher, as it provides
+ # a unicode object with provideAdapter, but I don't think I can
+ # change zope.publisher
+ from zope.app.publication.http import MethodNotAllowed
+ from zope.app.http.exception.methodnotallowed \
+ import MethodNotAllowedView
+ from zope.publisher.browser import BrowserRequest
+
+ context = C()
+ request = BrowserRequest(StringIO('PUT /bla/bla HTTP/1.1\n\n'), {})
+
+ error = MethodNotAllowed(context, request)
+ view = MethodNotAllowedView(error, request)
+
+ result = view()
+
+ self.assertEqual(request.response.getStatus(), 405)
+ #well this is empty, but we're grateful that it does not break
+ self.assertEqual(request.response.getHeader('Allow'), '')
+ self.assertEqual(result, 'Method Not Allowed')
+
+
def test_suite():
return TestSuite((
makeSuite(TestMethodNotAllowedView),
More information about the checkins
mailing list