18
18
self.folder = folder
21
def directory_listing(self, path, environ, start_response):
22
request = WSGIRequest(environ)
23
response = WSGIResponse()
24
listing = [d for d in os.listdir(path) if not d.startswith('.')]
25
response.headers['Content-Type'] = 'text/html'
26
print >> response, '<html><body>'
27
for d in sorted(listing):
28
if os.path.isdir(os.path.join(path, d)):
30
print >> response, '<li><a href="%s/">%s</a></li>' % (d, d)
31
print >> response, '</body></html>'
32
return response(environ, start_response)
34
def app_for_branch(self, b, path):
37
_history = History.from_branch(b)
38
_history.use_file_cache(FileChangeCache(_history, sql_dir))
40
name = os.path.basename(os.path.abspath(path))
43
h = BranchWSGIApp(_history, name).app
44
self.root.cache[path] = h
21
49
def __call__(self, environ, start_response):
22
50
path = os.path.join(self.root.folder, self.folder)
23
51
if not os.path.isdir(path):
31
59
if segment is None:
32
60
raise httpexceptions.HTTPMovedPermanently(environ['SCRIPT_NAME'] + '/')
33
61
elif segment == '':
34
request = WSGIRequest(environ)
35
response = WSGIResponse()
36
listing = [d for d in os.listdir(path) if not d.startswith('.')]
37
response.headers['Content-Type'] = 'text/html'
38
print >> response, '<html><body>'
39
for d in sorted(listing):
40
if os.path.isdir(os.path.join(path, d)):
42
print >> response, '<li><a href="%s/">%s</a></li>' % (d, d)
43
print >> response, '</body></html>'
44
return response(environ, start_response)
62
return self.directory_listing(path, environ, start_response)
46
64
relpath = os.path.join(self.folder, segment)
47
65
return BranchesFromFileSystemServer(relpath, self.root)(
48
66
environ, start_response)
52
_history = History.from_branch(b)
53
_history.use_file_cache(FileChangeCache(_history, sql_dir))
55
name = os.path.basename(os.path.abspath(path))
58
h = BranchWSGIApp(_history, name).app
59
self.root.cache[path] = h
60
return h(environ, start_response)
68
return self.app_for_branch(b, path)(environ, start_response)
64
71
class BranchesFromFileSystemRoot(object):
65
72
def __init__(self, folder):