I've been reading up on extending pyramid applications and trying this out. but it's not working as I expect.
Anyone see anything immediately wrong with this?
import unittest
from webtest import TestApp
from pyramid.configuration import Configurator
from pyramid.response import Response
def default_view(request):
return Response("")
def config_user_app(config, with_route=False):
if with_route:
route_name = "default"
else:
route_name = None
if route_name:
config.add_route(route_name, "/")
config.add_view(default_view, name="login", route_name=route_name)
config.add_view(default_view, name="logout", route_name=route_name)
class TestApplicationComposition(unittest.TestCase):
def testUserApp(self):
"""works"""
cfg = Configurator()
cfg.include(config_user_app)
app = TestApp(cfg.make_wsgi_app())
app.get("/login")
app.get("/logout")
def testIncluded(self):
"""
fails with 404
"""
route_prefix = "user"
cfg = Configurator()
cfg.include(config_user_app, route_prefix=route_prefix)
app = TestApp(cfg.make_wsgi_app())
app.get("/user/login")
app.get("/user/logout")