librelist archives

« back to archive

url rule about type path

url rule about type path

From:
Ken
Date:
2011-12-26 @ 10:24
Hi

I am writing some rules in type of path, not worked as expect.
code below:

from werkzeug.routing import Map,Rule

m = Map([
        Rule('/upload<path:f>', endpoint='upload'),
    ])

c = m.bind('example.com')
print(m)

url = c.build('upload', dict(f='foo/bar'))
print url, 'match', c.test(url)

url = c.build('upload', dict(f='/foo/bar'))
print url, 'match', c.test(url)

Map([<Rule '/upload<f>' -> upload>])
/uploadfoo/bar match True
/upload/foo/bar match False



My question is
 /upload/foo/bar match '/upload<path:f>' False, is right?

And how to handle "/upload/foo/bar" as upload(f="/foo/bar") ?


Thanks

-Ken