On Jan 9, 2:12 pm, Martin Aspeli <[email protected]> wrote: > Hi, > > I have a resource tree and I'm using traversal and named views. > However, I'd also like to support an /api/ namespace with different > views. So: > > http://example.org/foowould traverse from the root to the resource > foo and render the default (unnamed) view for context=Foo > > but > > http://example.org/api/foowould traverse to foo and render a JSON > representation of foo, using a different view > > I thought I could do this with hybrid routes, e.g: > > config.add_route('api', '/api/*traverse', factory=Root) > > I have a view for context=Root with route_name='api', and it is > rendered, but whenever I try to traverse further, e.g. to '/api/foo', > I get a 404. Moreover, I need some way to distinguish e.g. the unnamed > view on /foo from the unnamed view on /api/foo. > > What is the best way to do this?
Some more information: - I know the root factory (Root) is being called when traversing to / api/foo - I know that its __getitem__ is called and returns an object matching 'foo' when traversing to /api/foo - Traversal to /foo from the (custom) default root factory works and renders a view - Traversal to /foo/someview from the (custom) default root factory works and renders someview. This is defined with @view_config(context=Foo, renderer='json', name='someview', request_method='GET') - Traversal to /api/foo/someview from the 'api' root factory renders a 404 So, it almost looks to me like view lookup isn't happening when using the route to specify a custom root factory. Martin -- 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.
