diff options
| author | Tres Seaver <tseaver@palladion.com> | 2009-04-30 18:17:29 +0000 |
|---|---|---|
| committer | Tres Seaver <tseaver@palladion.com> | 2009-04-30 18:17:29 +0000 |
| commit | a6b51e9acbcd936114674ef7894aecfab061a42b (patch) | |
| tree | 26673bcaedbf1160c91bc5481acd796092b05987 /repoze | |
| parent | 27b87596a09ae4616b2445f85e6c4edea85114f9 (diff) | |
| download | pyramid-a6b51e9acbcd936114674ef7894aecfab061a42b.tar.gz pyramid-a6b51e9acbcd936114674ef7894aecfab061a42b.tar.bz2 pyramid-a6b51e9acbcd936114674ef7894aecfab061a42b.zip | |
Speed up / clarify 'traversal' module's 'model_path', 'model_path_tuple',
and '_model_path_list' functions.
Diffstat (limited to 'repoze')
| -rw-r--r-- | repoze/bfg/traversal.py | 19 |
1 files changed, 5 insertions, 14 deletions
diff --git a/repoze/bfg/traversal.py b/repoze/bfg/traversal.py index 40358ee7f..901368bba 100644 --- a/repoze/bfg/traversal.py +++ b/repoze/bfg/traversal.py @@ -180,11 +180,8 @@ def model_path(model, *elements): effectively replaced with a leading ``/``) when the path is generated. """ - path_list = _model_path_list(model, *elements) - if path_list: - path_list = [ quote_path_segment(name) for name in path_list ] - return '/' + '/'.join(path_list) - return '/' + path = _model_path_list(model, *elements) + return path and '/'.join([quote_path_segment(x) for x in path]) or '/' def model_path_tuple(model, *elements): """ @@ -220,19 +217,13 @@ def model_path_tuple(model, *elements): always be ignored (and effectively replaced with ``''``) when the path is generated. """ - path = _model_path_list(model, *elements) - if path: - return ('',) + tuple(path) - return ('',) + return tuple(_model_path_list(model, *elements)) def _model_path_list(model, *elements): """ Implementation detail shared by model_path and model_path_tuple """ - lpath = reversed(list(lineage(model))[:-1]) + lpath = reversed(list(lineage(model))) path = [ location.__name__ or '' for location in lpath ] - - if elements: - path = path + list(elements) - + path.extend(elements) return path def virtual_root(model, request): |
