On Sat, 2011-09-03 at 12:20 -0700, jazg wrote:
> If I have this:
> 
> config.include(include1, route_prefix="prefix")
> def include1(config):
>     config.include(include2)
> 
> Any routes added within the "include2" function will *not* have the
> prefix. It works if I pass route_prefix="/" to the second
> config.include, but this doesn't help me if I'm using something other
> than config.include. For example, I want to use add_static_view within
> the include so that the static route will have the prefix added to it.
> Is that possible?


This script appears to produce the correct behavior:

"""
from pyramid.view import view_config
from pyramid.config import Configurator
from pyramid.response import Response
from paste.httpserver import serve

@view_config(route_name='level0')
def level0_view(request):
    return Response('Level 0')

@view_config(route_name='level1')
def level1_view(request):
    return Response('Level 1')

@view_config(route_name='level2')
def level2_view(request):
    return Response('Level 2')

def level1_include(config):
    config.add_route('level1', '/')
    config.include(level2_include, route_prefix='/level2')

def level2_include(config):
    config.add_route('level2', '/')

if __name__ == '__main__':
    config = Configurator()
    config.add_route('level0', '/')
    config.include(level1_include, route_prefix='/level1')
    config.scan('__main__')
    serve(config.make_wsgi_app())
"""

http://localhost:8080/ -> "Level 0"
http://localhost:8080/level1/ -> "Level 1"
http://localhost:8080/level1/level2/ -> "Level 2"

Can you provide a script like this that doesn't do what you want it to?

- C


-- 
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.

Reply via email to