On Mon, Mar 5, 2012 at 7:44 AM, Thomas G. Willis <[email protected]>wrote:
> I've been reading up on extending pyramid applications and trying this > out. but it's not working as I expect. > > http://docs.pylonsproject.org/projects/pyramid/en/1.2-branch/narr/extending.html > > 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") > You need to do an add_route with your add_view for login/logout for this to work. For a breakdown of each you can check out: http://docs.pylonsproject.org/projects/pyramid/en/latest/narr/urldispatch.html http://docs.pylonsproject.org/projects/pyramid/en/latest/api/config.html#pyramid.config.Configurator.add_route http://docs.pylonsproject.org/projects/pyramid/en/latest/api/config.html#pyramid.config.Configurator.add_view -- You received this message because you are subscribed to the Google Groups "pylons-discuss" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en.
