If you use url traversal add_view() and not routes: You could use 'containment=<api>' in your view registration in combination with traversal. This view will onl match if the api object is somewhere in the parent chain. And api has to be an object.
Though you would have to add some object to definitely distinguish the first view 'http://example.org/foo' like 'http://example.org/html/foo' This would work for a complete subtree. Arndt. Am Montag, den 09.01.2012, 06:12 -0800 schrieb Martin Aspeli: > 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/foo would traverse from the root to the resource > foo and render the default (unnamed) view for context=Foo > > but > > http://example.org/api/foo would 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? > > Martin > -- _______________________________________________________________________ DV Electric Arndt Droullier Mail [email protected] Fon 0221/2725782 Fax 0221/2725783 Burgmauer 20, 50667 Köln http://www.dvelectric.com _______________________________________________________________________ -- 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.
