Hello,

I propose the following changes to pyramid/config/routes.py:
372c372,375
<             pattern = self.route_prefix.rstrip('/') + '/' + 
pattern.lstrip('/')
---
>             if pattern:
>                 pattern = self.route_prefix.rstrip('/') + '/' + 
pattern.lstrip('/')
>             else:
>                 pattern = self.route_prefix

Reasoning:
Take the following example:

from pyramid.config import Configurator

# maybe defined in some included application 

def routes(config):
    config.add_route('example', '')

# maybe the configuration of an including application 

if __name__ == '__main__':
    config = Configurator()
    config.include(routes, route_prefix="/prefix")


This will always generate the following route: 

myserver.com/prefix/

Notice the trailing "/" in the route, although I haven't specified it in my 
configuration.
With the change I posted above it would be possible to define, whether the 
final route should have a trailing "/" or not.

It would still have a bias towards having a trailing "/" as both the 
including and the included application can specify one:

# included application:

def routes(config):
    config.add_route('example', '/')


# including application:

if __name__ == '__main__':
    config = Configurator()
    config.include(routes, route_prefix="/prefix/")


This would both result in the following route:

myserver.com/prefix/

but the first example would have this route:

myserver.com/prefix

 
An existing trailing slash in either of the configurations wouldn't be 
removed and if there is none defined, it wouldn't be added. I think, that 
this would be the expected behavior.

Cheers,

   Andreas


-- 
You received this message because you are subscribed to the Google Groups 
"pylons-devel" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/pylons-devel/-/bLl5uf0Q414J.
To post to this group, send email to pylons-devel@googlegroups.com.
To unsubscribe from this group, send email to 
pylons-devel+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/pylons-devel?hl=en.

Reply via email to