~loggerhead-team/loggerhead/trunk-rich

« back to all changes in this revision

Viewing changes to loggerhead/apps/transport.py

  • Committer: Matt Nordhoff
  • Date: 2009-06-03 03:31:35 UTC
  • mfrom: (358.1.2 loggerhead)
  • mto: This revision was merged to the branch mainline in revision 367.
  • Revision ID: mnordhoff@mattnordhoff.com-20090603033135-gihr6e70o7t5eago
Merge smart server support

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
"""Serve branches at urls that mimic a transport's file system layout."""
2
2
 
3
3
from bzrlib import branch, errors, lru_cache, urlutils
 
4
from bzrlib.transport import get_transport
 
5
from bzrlib.transport.http import wsgi
4
6
 
5
7
from paste.request import path_info_pop
6
8
from paste import httpexceptions
71
73
    def __init__(self, transport, config):
72
74
        self.graph_cache = lru_cache.LRUCache(10)
73
75
        self.transport = transport
 
76
        self.readonly_transport = get_transport("readonly+" + 
 
77
            self.transport.base)
 
78
        wsgi_app = wsgi.SmartWSGIApp(self.readonly_transport)
 
79
        self.smart_server_app = wsgi.RelpathSetter(wsgi_app, '', 'PATH_INFO')
74
80
        self._config = config
75
81
 
76
82
    def __call__(self, environ, start_response):
81
87
            return static_app(environ, start_response)
82
88
        elif environ['PATH_INFO'] == '/favicon.ico':
83
89
            return favicon_app(environ, start_response)
 
90
        elif environ['PATH_INFO'].endswith("/.bzr/smart"):
 
91
            return self.smart_server_app(environ, start_response)
84
92
        elif '/.bzr/' in environ['PATH_INFO']:
85
93
            # TODO: Use something here that uses the transport API 
86
94
            # rather than relying on the local filesystem API.