~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/smart/request.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2009-12-03 00:17:53 UTC
  • mfrom: (4852.2.1 bzr-fix-publishing)
  • Revision ID: pqm@pqm.ubuntu.com-20091203001753-rrgwdoyxoojmn504
(David Roberts) Doc: delete unnecessary push of a checkout.

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
183
188
            relpath = urlutils.joinpath('/', path)
184
189
            if not relpath.startswith('/'):
185
190
                raise ValueError(relpath)
186
 
            return '.' + relpath
 
191
            return urlutils.escape('.' + relpath)
187
192
        else:
188
193
            raise errors.PathNotChild(client_path, self._root_client_path)
189
194
 
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=None):
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
        if jail_root is None:
 
285
            jail_root = backing_transport
 
286
        self._jail_root = jail_root
278
287
        self.response = None
279
288
        self.finished_reading = False
280
289
        self._command = None
292
301
        # cannot read after this.
293
302
        self.finished_reading = True
294
303
 
295
 
    def dispatch_command(self, cmd, args):
296
 
        """Deprecated compatibility method.""" # XXX XXX
297
 
        try:
298
 
            command = self._commands.get(cmd)
299
 
        except LookupError:
300
 
            raise errors.UnknownSmartMethod(cmd)
301
 
        self._command = command(self._backing_transport, self._root_client_path)
302
 
        self._run_handler_code(self._command.execute, args, {})
303
 
 
304
304
    def _run_handler_code(self, callable, args, kwargs):
305
305
        """Run some handler specific code 'callable'.
306
306
 
343
343
            command = self._commands.get(cmd)
344
344
        except LookupError:
345
345
            raise errors.UnknownSmartMethod(cmd)
346
 
        self._command = command(self._backing_transport)
 
346
        self._command = command(
 
347
            self._backing_transport, self._root_client_path, self._jail_root)
347
348
        self._run_handler_code(self._command.execute, args, {})
348
349
 
349
350
    def end_received(self):
509
510
request_handlers.register_lazy(
510
511
    'BzrDir.open', 'bzrlib.smart.bzrdir', 'SmartServerRequestOpenBzrDir')
511
512
request_handlers.register_lazy(
 
513
    'BzrDir.open_2.1', 'bzrlib.smart.bzrdir', 'SmartServerRequestOpenBzrDir_2_1')
 
514
request_handlers.register_lazy(
512
515
    'BzrDir.open_branch', 'bzrlib.smart.bzrdir',
513
516
    'SmartServerRequestOpenBranch')
514
517
request_handlers.register_lazy(