21
21
def __call__(self, environ, start_response):
22
segment = path_info_pop(environ)
24
f = os.path.join(self.root.folder, self.folder)
25
request = WSGIRequest(environ)
26
response = WSGIResponse()
27
listing = [d for d in os.listdir(f) if not d.startswith('.')]
28
response.headers['Content-Type'] = 'text/html'
29
print >> response, '<html><body>'
30
for d in sorted(listing):
32
print >> response, '<li><a href="%s/">%s</a></li>' % (d, d)
33
print >> response, '</body></html>'
34
return response(environ, start_response)
35
relpath = os.path.join(self.folder, segment)
36
f = os.path.join(self.root.folder, relpath)
37
if not os.path.isdir(f):
22
path = os.path.join(self.root.folder, self.folder)
23
if not os.path.isdir(path):
38
24
raise httpexceptions.HTTPNotFound()
39
if f in self.root.cache:
40
return self.root.cache[f](environ, start_response)
25
if path in self.root.cache:
26
return self.root.cache[path](environ, start_response)
42
b = branch.Branch.open(f)
28
b = branch.Branch.open(path)
43
29
except errors.NotBranchError:
44
return BranchesFromFileSystemServer(relpath, self.root)(environ, start_response)
30
segment = path_info_pop(environ)
32
request = WSGIRequest(environ)
33
response = WSGIResponse()
34
listing = [d for d in os.listdir(path) if not d.startswith('.')]
35
response.headers['Content-Type'] = 'text/html'
36
print >> response, '<html><body>'
37
for d in sorted(listing):
38
if os.path.isdir(os.path.join(path, d)):
40
print >> response, '<li><a href="%s/">%s</a></li>' % (d, d)
41
print >> response, '</body></html>'
42
return response(environ, start_response)
44
relpath = os.path.join(self.folder, segment)
45
return BranchesFromFileSystemServer(relpath, self.root)(
46
environ, start_response)
48
50
_history = History.from_branch(b)
49
51
_history.use_file_cache(FileChangeCache(_history, sql_dir))
50
h = BranchWSGIApp(_history, relpath).app
51
self.root.cache[f] = h
52
print '!!!', self.folder, path
54
name = os.path.basename(os.path.abspath(path))
57
h = BranchWSGIApp(_history, name).app
58
self.root.cache[path] = h
52
59
return h(environ, start_response)
59
66
self.folder = folder
60
67
def __call__(self, environ, start_response):
61
68
environ['loggerhead.static.url'] = environ['SCRIPT_NAME']
62
segment = path_info_pop(environ)
63
if segment == 'static':
69
if environ['PATH_INFO'].startswith('/static/'):
70
segment = path_info_pop(environ)
71
assert segment == 'static'
64
72
return static_app(environ, start_response)
66
74
return BranchesFromFileSystemServer(
67
segment, self)(environ, start_response)
75
'', self)(environ, start_response)
69
77
app = BranchesFromFileSystemRoot('.')