summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGES.txt15
-rw-r--r--repoze/bfg/tests/test_urldispatch.py15
-rw-r--r--repoze/bfg/urldispatch.py3
-rw-r--r--repoze/bfg/zcml.py5
4 files changed, 36 insertions, 2 deletions
diff --git a/CHANGES.txt b/CHANGES.txt
index 5af979c28..0c588a8ab 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -15,6 +15,21 @@ Bug Fixes
- ``bfg_routesalchemy`` paster template: change ``<route>``
declarations: rename ``renderer`` attribute to ``view_renderer``.
+- Header values returned by the ``authtktauthenticationpolicy``
+ ``remember`` and ``forget`` methods would be of type ``unicode`` if
+ the ``cookie_name`` attribute was used in the ZCML declaration.
+ This violated the WSGI spec, causing a ``TypeError`` to be raised
+ when these headers were used under ``mod_wsgi``.
+
+- If a routes-only BFG app was mounted under a path in modwsgi, ala
+ ``WSGIScriptAlias /myapp
+ /Users/chrism/projects/modwsgi/env/bfg.wsgi``, the home route (a
+ route with the path of ``'/'`` or ``''``) would not match when the
+ path ``/myapp`` was visited (only when the path ``/myapp/`` was
+ visited). This is now fixed: if the urldispatch root factory notes
+ that the PATH_INFO is empty, it converts it to a single slash before
+ trying to do matching.
+
Documentation
-------------
diff --git a/repoze/bfg/tests/test_urldispatch.py b/repoze/bfg/tests/test_urldispatch.py
index 83e908994..803f4503f 100644
--- a/repoze/bfg/tests/test_urldispatch.py
+++ b/repoze/bfg/tests/test_urldispatch.py
@@ -194,6 +194,21 @@ class RoutesRootFactoryTests(unittest.TestCase):
self.assertEqual(request.matchdict, {})
self.failUnless(req_iface.providedBy(request))
+ def test_root_route_when_path_info_empty(self):
+ root_factory = DummyRootFactory(123)
+ req_iface = self._registerRouteRequest('root')
+ mapper = self._makeOne(root_factory)
+ mapper.connect('/', 'root')
+ request = self._getRequest(PATH_INFO='')
+ result = mapper(request)
+ environ = request.environ
+ self.assertEqual(result, 123)
+ self.assertEqual(environ['bfg.routes.route'].name, 'root')
+ self.assertEqual(environ['bfg.routes.matchdict'], {})
+ self.assertEqual(environ['wsgiorg.routing_args'], ((), {}))
+ self.assertEqual(request.matchdict, {})
+ self.failUnless(req_iface.providedBy(request))
+
def test_fallback_to_default_root_factory(self):
root_factory = DummyRootFactory(123)
mapper = self._makeOne(root_factory)
diff --git a/repoze/bfg/urldispatch.py b/repoze/bfg/urldispatch.py
index 715fb07e4..373c11f0b 100644
--- a/repoze/bfg/urldispatch.py
+++ b/repoze/bfg/urldispatch.py
@@ -68,6 +68,9 @@ class RoutesRootFactory(object):
path = environ['PATH_INFO']
except KeyError:
path = '/'
+ if not path: # empty if mounted under a path in mod_wsgi, for example
+ path = '/'
+
for route in self.routelist:
match = route.match(path)
if match is not None:
diff --git a/repoze/bfg/zcml.py b/repoze/bfg/zcml.py
index 2bec8b77a..06c4f076e 100644
--- a/repoze/bfg/zcml.py
+++ b/repoze/bfg/zcml.py
@@ -15,6 +15,7 @@ from zope.interface.interfaces import IInterface
from zope.schema import Bool
from zope.schema import Int
from zope.schema import TextLine
+from zope.schema import ASCIILine
import martian
@@ -501,8 +502,8 @@ def remoteuserauthenticationpolicy(_context, environ_key='REMOTE_USER',
class IAuthTktAuthenticationPolicyDirective(Interface):
secret = TextLine(title=u'secret', required=True)
callback = GlobalObject(title=u'callback', required=False)
- cookie_name = TextLine(title=u'cookie_name', required=False,
- default=u'repoze.bfg.auth_tkt')
+ cookie_name = ASCIILine(title=u'cookie_name', required=False,
+ default='repoze.bfg.auth_tkt')
secure = Bool(title=u"secure", required=False, default=False)
include_ip = Bool(title=u"include_ip", required=False, default=False)
timeout = Int(title=u"timeout", required=False, default=None)