diff options
| author | Chris McDonough <chrism@agendaless.com> | 2008-07-05 00:43:33 +0000 |
|---|---|---|
| committer | Chris McDonough <chrism@agendaless.com> | 2008-07-05 00:43:33 +0000 |
| commit | 1da614e3dab88f4a7ccf97630e808c1c119a0f90 (patch) | |
| tree | c7148708adeeb9b47af6f2ebc85844e941bb7a2f /repoze/bfg/policy.py | |
| parent | 8f88693600edebb522b6d078691e72a0dcbdb287 (diff) | |
| download | pyramid-1da614e3dab88f4a7ccf97630e808c1c119a0f90.tar.gz pyramid-1da614e3dab88f4a7ccf97630e808c1c119a0f90.tar.bz2 pyramid-1da614e3dab88f4a7ccf97630e808c1c119a0f90.zip | |
policy -> traversal.
Diffstat (limited to 'repoze/bfg/policy.py')
| -rw-r--r-- | repoze/bfg/policy.py | 47 |
1 files changed, 0 insertions, 47 deletions
diff --git a/repoze/bfg/policy.py b/repoze/bfg/policy.py deleted file mode 100644 index 697350b16..000000000 --- a/repoze/bfg/policy.py +++ /dev/null @@ -1,47 +0,0 @@ -import urllib - -from zope.interface import implements - -from repoze.bfg.interfaces import ITraversalPolicy -from repoze.bfg.interfaces import ITraverser - -def split_path(path): - if path.startswith('/'): - path = path[1:] - if path.endswith('/'): - path = path[:-1] - clean=[] - for item in path.split('/'): - item = urllib.unquote(item) # deal with spaces in path segment - if not item or item=='.': - continue - elif item == '..': - del clean[-1] - else: - clean.append(item) - return clean - -class NaiveTraversalPolicy: - implements(ITraversalPolicy) - - def __call__(self, environ, root): - path = split_path(environ['PATH_INFO']) - - ob = root - name = '' - - while path: - element = pop(path) - traverser = ITraverser(ob) - next = traverser(environ, element) - if next is None: - if path: - name = pop(path) - break - ob = next - - return ob, name, path - -def pop(path): - return path.pop(0) - |
