~loggerhead-team/loggerhead/trunk-rich

« back to all changes in this revision

Viewing changes to serve-branches

  • Committer: Martin Albisetti
  • Date: 2008-10-24 17:54:06 UTC
  • mfrom: (230.1.2 pep8)
  • Revision ID: martin.albisetti@canonical.com-20081024175406-73bpc73m7pshat9c
PEP8 fixes

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
from optparse import OptionParser
23
23
 
24
24
from paste import httpserver
25
 
from paste.httpexceptions import HTTPExceptionHandler, HTTPInternalServerError
 
25
from paste.httpexceptions import HTTPExceptionHandler
26
26
from paste.translogger import TransLogger
27
27
 
28
28
from loggerhead import __version__
50
50
                      help="Host Loggerhead should listen on.")
51
51
    parser.add_option("--prefix", dest="user_prefix",
52
52
                      help="Specify host prefix.")
53
 
    parser.add_option("--profile", action="store_true", dest="profile",
54
 
                      help="Generate callgrind profile data to "
55
 
                        "%d-stats.callgrind on each request.")
56
53
    parser.add_option("--reload", action="store_true", dest="reload",
57
54
                      help="Restarts the application when changing python"
58
55
                           " files. Only used for development purposes.")
116
113
    logfile.setLevel(logging.DEBUG)
117
114
    logger.addHandler(logfile)
118
115
    # setup_logging() #end
 
116
    app = ErrorHandlerApp(app)
 
117
    app = HTTPExceptionHandler(app)
119
118
    app = TransLogger(app, logger=logger)
120
 
    if options.profile:
121
 
        from loggerhead.middleware.profile import LSProfMiddleware
122
 
        app = LSProfMiddleware(app)
123
119
 
124
120
    if not options.user_prefix:
125
121
        prefix = '/'
129
125
    try:
130
126
        from paste.deploy.config import PrefixMiddleware
131
127
    except ImportError:
132
 
        cant_proxy_correctly_message = (
133
 
            'Unsupported configuration: PasteDeploy not available, but '
134
 
            'loggerhead appears to be behind a proxy.')
135
 
        def check_not_proxied(app):
136
 
            def wrapped(environ, start_response):
137
 
                if 'HTTP_X_FORWARDED_SERVER' in environ:
138
 
                    exc = HTTPInternalServerError()
139
 
                    exc.explanation = cant_proxy_correctly_message
140
 
                    raise exc
141
 
                return app(environ, start_response)
142
 
            return wrapped
143
 
        app = check_not_proxied(app)
 
128
        pass
144
129
    else:
145
130
        app = PrefixMiddleware(app, prefix=prefix)
146
131
 
147
 
    app = ErrorHandlerApp(app)
148
 
    app = HTTPExceptionHandler(app)
149
 
 
150
132
    if not options.user_port:
151
133
        port = '8080'
152
134
    else: