Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

- Views associated with routes with spaces in the route name may not …

…have

  been looked up correctly when using Pyramid with ``zope.interface`` 3.6.4
  and better.

Closes #232.
  • Loading branch information...
commit 873d9be3a787793caeb66223d2bb68dbc1fc396e 1 parent d05117e
@mcdonc mcdonc authored
View
4 CHANGES.txt
@@ -49,6 +49,10 @@ Bug Fixes
exception view will be working with a request.response that has not been
touched by any code prior to the exception.
+- Views associated with routes with spaces in the route name may not have
+ been looked up correctly when using Pyramid with ``zope.interface`` 3.6.4
+ and better.
+
Documentation
-------------
View
15 pyramid/request.py
@@ -496,10 +496,19 @@ def json_body(self):
def route_request_iface(name, bases=()):
- iface = InterfaceClass('%s_IRequest' % name, bases=bases)
+ # zope.interface treats the __name__ as the __doc__ and changes __name__
+ # to None for interfaces that contain spaces if you do not pass a
+ # nonempty __doc__ (insane); see
+ # zope.interface.interface.Element.__init__ and
+ # https://github.com/Pylons/pyramid/issues/232; as a result, always pass
+ # __doc__ to the InterfaceClass constructor.
+ iface = InterfaceClass('%s_IRequest' % name, bases=bases,
+ __doc__="route_request_iface-generated interface")
# for exception view lookups
- iface.combined = InterfaceClass('%s_combined_IRequest' % name,
- bases=(iface, IRequest))
+ iface.combined = InterfaceClass(
+ '%s_combined_IRequest' % name,
+ bases=(iface, IRequest),
+ __doc__ = 'route_request_iface-generated combined interface')
return iface
def add_global_response_headers(request, headerlist):
View
9 pyramid/tests/test_request.py
@@ -424,6 +424,15 @@ def test_it(self):
self.assertTrue(hasattr(iface, 'combined'))
self.assertEqual(iface.combined.__name__, 'routename_combined_IRequest')
+ def test_it_routename_with_spaces(self):
+ # see https://github.com/Pylons/pyramid/issues/232
+ iface = self._callFUT('routename with spaces')
+ self.assertEqual(iface.__name__, 'routename with spaces_IRequest')
+ self.assertTrue(hasattr(iface, 'combined'))
+ self.assertEqual(iface.combined.__name__,
+ 'routename with spaces_combined_IRequest')
+
+
class Test_add_global_response_headers(unittest.TestCase):
def _callFUT(self, request, headerlist):
from pyramid.request import add_global_response_headers
Please sign in to comment.
Something went wrong with that request. Please try again.