blob: 72f7b39417c38631444724072416cae8072ff13a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
from filebrowser.sitepage import *
class jump(SitePage):
def setup(self):
name = self.fields.name.strip()
action = 'view'
if name.startswith('edit:'):
action = 'edit'
name = name[5:].strip()
root = self.pathcontext.path('/')
if name == 'root':
possible = [root]
else:
possible = root.find_filename(name)
if not possible:
self.message.write('No files with %r found' % name)
self.redirect(self.environ['HTTP_REFERER'])
dest = possible[0]
if possible[1:]:
self.message.write('Other matches:')
for path in possible[1:]:
self.message.write(
'<a href="%s">%s</a>'
% (self.pathurl(path.path, action=action), path.path))
self.redirect(self.pathurl(dest.path, action=action))
|