b.s.m.SmartClientMedium(SmartMedium) : class documentation

Part of bzrlib.smart.medium View In Hierarchy

Known subclasses: bzrlib.smart.medium.SmartClientStreamMedium, bzrlib.tests.test_remote.FakeMedium, bzrlib.tests.test_smart_transport.MockMedium, bzrlib.transport.http.SmartClientHTTPMedium

Smart client is a medium for sending smart protocol requests over.
Method __init__ Undocumented
Method protocol_version Find out if 'hello' smart request works.
Method should_probe Should RemoteBzrDirFormat.probe_transport send a smart request on
Method disconnect If this medium maintains a persistent connection, close it.
Method remote_path_from_transport Convert transport into a path suitable for using in a request.
Method _is_remote_before Is it possible the remote side supports RPCs for a given version?
Method _remember_remote_is_before Tell this medium that the remote side is older the given version.

Inherited from SmartMedium:

Method read_bytes Read some bytes from this medium.
Method _push_back Return unused bytes to the medium, because they belong to the next
Method _get_push_back_buffer Undocumented
Method _read_bytes Undocumented
Method _get_line Read bytes from this request's response until a newline byte.
Method _report_activity Notify that this medium has activity.
def __init__(self, base):
Undocumented
def _is_remote_before(self, version_tuple):

Is it possible the remote side supports RPCs for a given version?

Typical use:

needed_version = (1, 2)
if medium._is_remote_before(needed_version):
    fallback_to_pre_1_2_rpc()
else:
    try:
        do_1_2_rpc()
    except UnknownSmartMethod:
        medium._remember_remote_is_before(needed_version)
        fallback_to_pre_1_2_rpc()
See Also_remember_remote_is_before
def _remember_remote_is_before(self, version_tuple):
Tell this medium that the remote side is older the given version.
See Also_is_remote_before
def protocol_version(self):
Find out if 'hello' smart request works.
def should_probe(self):
Should RemoteBzrDirFormat.probe_transport send a smart request on this medium?

Some transports are unambiguously smart-only; there's no need to check if the transport is able to carry smart requests, because that's all it is for. In those cases, this method should return False.

But some HTTP transports can sometimes fail to carry smart requests, but still be usuable for accessing remote bzrdirs via plain file accesses. So for those transports, their media should return True here so that RemoteBzrDirFormat can determine if it is appropriate for that transport.

def disconnect(self):
If this medium maintains a persistent connection, close it.

The default implementation does nothing.

def remote_path_from_transport(self, transport):
Convert transport into a path suitable for using in a request.

Note that the resulting remote path doesn't encode the host name or anything but path, so it is only safe to use it in requests sent over the medium from the matching transport.

API Documentation for Bazaar, generated by pydoctor at 2022-06-16 00:25:16.