Return a generator for routes that match the signature (name, args) of the func parameter. This may yield more than one route if the function takes optional keyword arguments. The output is best described by example:: a() -> '/a' b(x, y) -> '/b/ / '
(func)
| 2635 | |
| 2636 | |
| 2637 | def yieldroutes(func): |
| 2638 | """ Return a generator for routes that match the signature (name, args) |
| 2639 | of the func parameter. This may yield more than one route if the function |
| 2640 | takes optional keyword arguments. The output is best described by example:: |
| 2641 | |
| 2642 | a() -> '/a' |
| 2643 | b(x, y) -> '/b/<x>/<y>' |
| 2644 | c(x, y=5) -> '/c/<x>' and '/c/<x>/<y>' |
| 2645 | d(x=5, y=6) -> '/d' and '/d/<x>' and '/d/<x>/<y>' |
| 2646 | """ |
| 2647 | path = '/' + func.__name__.replace('__','/').lstrip('/') |
| 2648 | spec = getargspec(func) |
| 2649 | argc = len(spec[0]) - len(spec[3] or []) |
| 2650 | path += ('/<%s>' * argc) % tuple(spec[0][:argc]) |
| 2651 | yield path |
| 2652 | for arg in spec[0][argc:]: |
| 2653 | path += '/<%s>' % arg |
| 2654 | yield path |
| 2655 | |
| 2656 | |
| 2657 | def path_shift(script_name, path_info, shift=1): |