~loggerhead-team/loggerhead/trunk-rich

« back to all changes in this revision

Viewing changes to serve-branches

  • Committer: Michael Hudson
  • Date: 2009-02-24 01:46:23 UTC
  • mfrom: (270.3.20 no-more-mootools)
  • Revision ID: michael.hudson@canonical.com-20090224014623-44zenkmtzus7xo3x
merge no-more-mootools
this removes all use of mootools and switches over to YUI3 PR2 for all the
dynamic stuff.

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
 
24
26
from paste import httpserver
25
 
from paste.httpexceptions import HTTPExceptionHandler
 
27
from paste.httpexceptions import HTTPExceptionHandler, HTTPInternalServerError
26
28
from paste.translogger import TransLogger
27
29
 
28
30
from loggerhead import __version__
116
118
    logfile.setLevel(logging.DEBUG)
117
119
    logger.addHandler(logfile)
118
120
    # 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
131
131
    try:
132
132
        from paste.deploy.config import PrefixMiddleware
133
133
    except ImportError:
134
 
        pass
 
134
        cant_proxy_correctly_message = (
 
135
            'Unsupported configuration: PasteDeploy not available, but '
 
136
            'loggerhead appears to be behind a proxy.')
 
137
        def check_not_proxied(app):
 
138
            def wrapped(environ, start_response):
 
139
                if 'HTTP_X_FORWARDED_SERVER' in environ:
 
140
                    exc = HTTPInternalServerError()
 
141
                    exc.explanation = cant_proxy_correctly_message
 
142
                    raise exc
 
143
                return app(environ, start_response)
 
144
            return wrapped
 
145
        app = check_not_proxied(app)
135
146
    else:
136
147
        app = PrefixMiddleware(app, prefix=prefix)
137
148
 
 
149
    app = HTTPExceptionHandler(app)
 
150
    app = ErrorHandlerApp(app)
 
151
 
138
152
    if not options.user_port:
139
153
        port = '8080'
140
154
    else:
145
159
    else:
146
160
        host = options.user_host
147
161
 
 
162
    load_plugins()
 
163
 
148
164
    httpserver.serve(app, host=host, port=port)
149
165
 
150
166