/loggerhead/trunk

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/loggerhead/trunk

« back to all changes in this revision

Viewing changes to loggerhead.wsgi

  • Committer: Colin Watson
  • Date: 2019-09-19 08:10:36 UTC
  • mfrom: (491.2.62 breezy)
  • Revision ID: cjwatson@canonical.com-20190919081036-q1symc2h2iedtlh3
[r=cjwatson] Switch loggerhead over to using the Breezy rather than Bazaar APIs.

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
from loggerhead.apps.transport import BranchesFromTransportRoot
24
24
from loggerhead.apps.error import ErrorHandlerApp
25
25
from loggerhead.config import LoggerheadConfig
26
 
from bzrlib import config as bzrconfig
 
26
from breezy import config as bzrconfig
 
27
from breezy.sixish import PY3
27
28
from paste.deploy.config import PrefixMiddleware
28
 
from bzrlib.plugin import load_plugins
 
29
from breezy.plugin import load_plugins
29
30
 
30
31
class NotConfiguredError(Exception):
31
32
    pass
36
37
prefix = config.get_option('user_prefix') or ''
37
38
# Note we could use LoggerheadConfig here if it didn't fail when a
38
39
# config option is not also a commandline option
39
 
root_dir = bzrconfig.GlobalConfig().get_user_option('http_root_dir')
40
 
if not root_dir:
41
 
    raise NotConfiguredError('You must have a ~/.bazaar/bazaar.conf file for'
 
40
root_dir = os.getenv('LOGGERHEAD_ROOT_DIR')
 
41
if not root_dir:
 
42
    root_dir = bzrconfig.GlobalConfig().get_user_option('http_root_dir')
 
43
if not root_dir:
 
44
    raise NotConfiguredError('You must set LOGGERHEAD_ROOT_DIR or have '
 
45
            'a ~/.config/breezy/breezy.conf file for'
42
46
            ' %(user)s with http_root_dir set to the base directory you want'
43
47
            ' to serve bazaar repositories from' %
44
48
            {'user': pwd.getpwuid(os.geteuid()).pw_name})
45
 
prefix = prefix.encode('utf-8', 'ignore')
46
 
root_dir = root_dir.encode('utf-8', 'ignore')
 
49
if not PY3:
 
50
    prefix = prefix.encode('utf-8', 'ignore')
 
51
    root_dir = root_dir.encode('utf-8', 'ignore')
47
52
app = BranchesFromTransportRoot(root_dir, config)
48
53
app = PrefixMiddleware(app, prefix=prefix)
49
54
app = HTTPExceptionHandler(app)