~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/smart/client.py

merge hpss again; restore incorrectly removed RemoteRepository.break_lock

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
 
28
28
    def call(self, method, *args):
29
29
        """Call a method on the remote server."""
30
 
        result, protocol = self.call2(method, *args)
 
30
        result, protocol = self.call_expecting_body(method, *args)
31
31
        protocol.cancel_read_body()
32
32
        return result
33
33
 
34
 
    def call2(self, method, *args):
35
 
        """Call a method and return the result and the protocol object."""
 
34
    def call_expecting_body(self, method, *args):
 
35
        """Call a method and return the result and the protocol object.
 
36
        
 
37
        The body can be read like so::
 
38
 
 
39
            result, smart_protocol = smart_client.call_expecting_body(...)
 
40
            body = smart_protocol.read_body_bytes()
 
41
        """
36
42
        request = self._medium.get_request()
37
43
        smart_protocol = protocol.SmartClientRequestProtocolOne(request)
38
44
        smart_protocol.call(method, *args)
53
59
        return smart_protocol.read_response_tuple()
54
60
 
55
61
    def remote_path_from_transport(self, transport):
56
 
        """Convert transport into a path suitable for using in a request."""
 
62
        """Convert transport into a path suitable for using in a request.
 
63
        
 
64
        Note that the resulting remote path doesn't encode the host name or
 
65
        anything but path, so it is only safe to use it in requests sent over
 
66
        the medium from the matching transport.
 
67
        """
57
68
        return unescape(urlparse(transport.base)[2]).encode('utf8')