~loggerhead-team/loggerhead/trunk-rich

« back to all changes in this revision

Viewing changes to loggerhead.wsgi

  • Committer: Matt Nordhoff
  • Date: 2009-10-17 08:59:33 UTC
  • mto: (329.2.5 trailing-whitespace)
  • mto: This revision was merged to the branch mainline in revision 392.
  • Revision ID: mnordhoff@mattnordhoff.com-20091017085933-cizgmza5khtley6b
Replace "while 1" with "while True".

Actually, 3 of these were in a piece of duplicated code. Maybe it should be factored out into a function.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/usr/bin/python -tt
2
 
 
3
 
import sys
4
 
import os
5
 
import pwd
6
 
sys.path.insert(0, os.path.dirname(__file__))
7
 
 
8
 
from paste.httpexceptions import HTTPExceptionHandler
9
 
from loggerhead.apps.transport import BranchesFromTransportRoot
10
 
from loggerhead.apps.error import ErrorHandlerApp
11
 
from loggerhead.config import LoggerheadConfig
12
 
from bzrlib import config as bzrconfig
13
 
from paste.deploy.config import PrefixMiddleware
14
 
from bzrlib.plugin import load_plugins
15
 
 
16
 
class NotConfiguredError(Exception):
17
 
    pass
18
 
 
19
 
 
20
 
load_plugins()
21
 
config = LoggerheadConfig()
22
 
prefix = config.get_option('user_prefix') or ''
23
 
# Note we could use LoggerheadConfig here if it didn't fail when a
24
 
# config option is not also a commandline option
25
 
root_dir = bzrconfig.GlobalConfig().get_user_option('http_root_dir')
26
 
if not root_dir:
27
 
    raise NotConfiguredError('You must have a ~/.bazaar/bazaar.conf file for'
28
 
            ' %(user)s with http_root_dir set to the base directory you want'
29
 
            ' to serve bazaar repositories from' %
30
 
            {'user': pwd.getpwuid(os.geteuid()).pw_name})
31
 
prefix = prefix.encode('utf-8', 'ignore')
32
 
root_dir = root_dir.encode('utf-8', 'ignore')
33
 
app = BranchesFromTransportRoot(root_dir, config)
34
 
app = PrefixMiddleware(app, prefix=prefix)
35
 
app = HTTPExceptionHandler(app)
36
 
application = ErrorHandlerApp(app)