~loggerhead-team/loggerhead/trunk-rich

« back to all changes in this revision

Viewing changes to wsgitest.py

  • Committer: Michael Hudson
  • Date: 2008-06-16 10:56:29 UTC
  • mto: This revision was merged to the branch mainline in revision 164.
  • Revision ID: michael.hudson@canonical.com-20080616105629-ea9dahymo4rl9cad
improvements borne out of the fires of contact with reality &c

Show diffs side-by-side

added added

removed removed

Lines of Context:
7
7
from paste import httpserver
8
8
from paste.httpexceptions import make_middleware
9
9
from paste.translogger import make_filter
 
10
from loggerhead.changecache import FileChangeCache
10
11
 
11
12
 
12
13
 
19
20
        segment = path_info_pop(environ)
20
21
        if segment is None:
21
22
            raise httpexceptions.HTTPNotFound()
22
 
        f = os.path.join(self.folder, segment)
23
 
        print f
 
23
        relpath = os.path.join(self.folder, segment)
 
24
        f = os.path.join(self.root.folder, relpath)
24
25
        if not os.path.isdir(f):
25
26
            raise httpexceptions.HTTPNotFound()
26
27
        if f in self.root.cache:
28
29
        try:
29
30
            b = branch.Branch.open(f)
30
31
        except errors.NotBranchError:
31
 
            return BranchesFromFileSystemServer(f, self.root)(environ, start_response)
 
32
            return BranchesFromFileSystemServer(relpath, self.root)(environ, start_response)
32
33
        else:
33
34
            b.lock_read()
34
35
            try:
35
 
                h = BranchWSGIApp(History.from_branch(b), 'hello').app
 
36
                _history = History.from_branch(b)
 
37
                _history.use_file_cache(FileChangeCache(_history, 'sql'))
 
38
                h = BranchWSGIApp(_history, relpath).app
36
39
                self.root.cache[f] = h
37
40
                return h(environ, start_response)
38
41
            finally:
49
52
            return static_app(environ, start_response)
50
53
        else:
51
54
            return BranchesFromFileSystemServer(
52
 
                os.path.join(self.folder, segment), self)(environ, start_response)
 
55
                segment, self)(environ, start_response)
53
56
 
54
57
app = BranchesFromFileSystemRoot('../..')
55
58