~loggerhead-team/loggerhead/trunk-rich

« back to all changes in this revision

Viewing changes to __init__.py

  • Committer: Matt Nordhoff
  • Date: 2009-06-03 03:30:38 UTC
  • mto: (359.3.3 hpss-writes)
  • mto: This revision was merged to the branch mainline in revision 362.
  • Revision ID: mnordhoff@mattnordhoff.com-20090603033038-v7rycl4x7ivrxhit
Add an --allow-writes option to serve-branches and "bzr serve"

Show diffs side-by-side

added added

removed removed

Lines of Context:
70
70
            host = DEFAULT_HOST
71
71
        if port is None:
72
72
            port = DEFAULT_PORT
73
 
        argv = ['--host', host, '--port', str(port), transport.base]
 
73
        allow_writes = not transport.is_readonly()
 
74
        argv = ['--host', host, '--port', str(port),
 
75
            '--allow-writes', allow_writes, transport.base]
74
76
        config = LoggerheadConfig(argv)
75
77
        app = BranchesFromTransportRoot(transport, config)
76
78
        app = HTTPExceptionHandler(app)
94
96
            def run(self, *args, **kw):
95
97
                if 'http' in kw:
96
98
                    from bzrlib.transport import get_transport
 
99
                    allow_writes = kw.get('allow_writes', False)
97
100
                    path = kw.get('directory', '.')
98
101
                    port = kw.get('port', DEFAULT_PORT)
99
102
                    # port might be an int already...
101
104
                        host, port = port.split(':')
102
105
                    else:
103
106
                        host = DEFAULT_HOST
104
 
                    transport = get_transport(path)
 
107
                    if allow_writes:
 
108
                        transport = get_transport(path)
 
109
                    else:
 
110
                        transport = get_transport('readonly+' + path)
105
111
                    serve_http(transport, host, port)
106
112
                else:
107
113
                    super(cmd_serve, self).run(*args, **kw)