~loggerhead-team/loggerhead/trunk-rich

« back to all changes in this revision

Viewing changes to serve-branches

  • Committer: Martin Albisetti
  • Date: 2008-12-05 20:12:10 UTC
  • mfrom: (247.1.2 memfixes)
  • Revision ID: argentina@gmail.com-20081205201210-s7i0pknhjynijkvi
Change API used to get branch nicks so they don't access the network with checkouts. (Martin Albisetti, James Westby and Robert Collins' brain)

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
 
22
22
from optparse import OptionParser
23
23
 
24
 
from bzrlib.plugin import load_plugins
25
 
 
26
24
from paste import httpserver
27
 
from paste.httpexceptions import HTTPExceptionHandler, HTTPInternalServerError
 
25
from paste.httpexceptions import HTTPExceptionHandler
28
26
from paste.translogger import TransLogger
29
27
 
30
28
from loggerhead import __version__
118
116
    logfile.setLevel(logging.DEBUG)
119
117
    logger.addHandler(logfile)
120
118
    # setup_logging() #end
 
119
    app = ErrorHandlerApp(app)
 
120
    app = HTTPExceptionHandler(app)
121
121
    app = TransLogger(app, logger=logger)
122
122
    if options.profile:
123
123
        from loggerhead.middleware.profile import LSProfMiddleware
127
127
        prefix = '/'
128
128
    else:
129
129
        prefix = options.user_prefix
130
 
        if not prefix.startswith('/'):
131
 
            prefix = '/' + prefix
132
130
 
133
131
    try:
134
132
        from paste.deploy.config import PrefixMiddleware
135
133
    except ImportError:
136
 
        cant_proxy_correctly_message = (
137
 
            'Unsupported configuration: PasteDeploy not available, but '
138
 
            'loggerhead appears to be behind a proxy.')
139
 
        def check_not_proxied(app):
140
 
            def wrapped(environ, start_response):
141
 
                if 'HTTP_X_FORWARDED_SERVER' in environ:
142
 
                    exc = HTTPInternalServerError()
143
 
                    exc.explanation = cant_proxy_correctly_message
144
 
                    raise exc
145
 
                return app(environ, start_response)
146
 
            return wrapped
147
 
        app = check_not_proxied(app)
 
134
        pass
148
135
    else:
149
136
        app = PrefixMiddleware(app, prefix=prefix)
150
137
 
151
 
    app = HTTPExceptionHandler(app)
152
 
    app = ErrorHandlerApp(app)
153
 
 
154
138
    if not options.user_port:
155
139
        port = '8080'
156
140
    else:
161
145
    else:
162
146
        host = options.user_host
163
147
 
164
 
    load_plugins()
165
 
 
166
148
    httpserver.serve(app, host=host, port=port)
167
149
 
168
150