~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/smart/request.py

  • Committer: Andrew Bennetts
  • Date: 2009-10-21 06:05:49 UTC
  • mto: This revision was merged to the branch mainline in revision 4762.
  • Revision ID: andrew.bennetts@canonical.com-20091021060549-8i7as0iacaixvckh
Add optional jail_root argument to SmartServerRequest and friends, and use it in the WSGI glue.  Allows opening branches in shared repos via bzr+http (assuming the repo should be accessible).

Show diffs side-by-side

added added

removed removed

Lines of Context:
86
86
    # XXX: rename this class to BaseSmartServerRequestHandler ?  A request
87
87
    # *handler* is a different concept to the request.
88
88
 
89
 
    def __init__(self, backing_transport, root_client_path='/'):
 
89
    def __init__(self, backing_transport, root_client_path='/', jail_root=None):
90
90
        """Constructor.
91
91
 
92
92
        :param backing_transport: the base transport to be used when performing
96
96
            from the client.  Clients will not be able to refer to paths above
97
97
            this root.  If root_client_path is None, then no translation will
98
98
            be performed on client paths.  Default is '/'.
 
99
        :param jail_root: if specified, the root of the BzrDir.open jail to use
 
100
            instead of backing_transport.
99
101
        """
100
102
        self._backing_transport = backing_transport
 
103
        if jail_root is None:
 
104
            jail_root = backing_transport
 
105
        self._jail_root = jail_root
101
106
        if root_client_path is not None:
102
107
            if not root_client_path.startswith('/'):
103
108
                root_client_path = '/' + root_client_path
155
160
        return self.do_body(body_bytes)
156
161
 
157
162
    def setup_jail(self):
158
 
        jail_info.transports = [self._backing_transport]
 
163
        jail_info.transports = [self._jail_root]
159
164
 
160
165
    def teardown_jail(self):
161
166
        jail_info.transports = None
265
270
    # TODO: Better way of representing the body for commands that take it,
266
271
    # and allow it to be streamed into the server.
267
272
 
268
 
    def __init__(self, backing_transport, commands, root_client_path):
 
273
    def __init__(self, backing_transport, commands, root_client_path,
 
274
        jail_root):
269
275
        """Constructor.
270
276
 
271
277
        :param backing_transport: a Transport to handle requests for.
275
281
        self._backing_transport = backing_transport
276
282
        self._root_client_path = root_client_path
277
283
        self._commands = commands
 
284
        self._jail_root = jail_root
278
285
        self.response = None
279
286
        self.finished_reading = False
280
287
        self._command = None
335
342
        except LookupError:
336
343
            raise errors.UnknownSmartMethod(cmd)
337
344
        self._command = command(
338
 
            self._backing_transport, self._root_client_path)
 
345
            self._backing_transport, self._root_client_path, self._jail_root)
339
346
        self._run_handler_code(self._command.execute, args, {})
340
347
 
341
348
    def end_received(self):