Part of bzrlib.transport View In Hierarchy
Known subclasses: bzrlib.transport.ftp.FtpTransport, bzrlib.transport.gio_transport.GioTransport, bzrlib.transport.http.HttpTransportBase, bzrlib.transport.remote.RemoteTransport, bzrlib.transport.sftp.SFTPTransport
This class provide the basis to implement transports that need to connect to a remote server.
Host and credentials are available as private attributes, cloning preserves them and share the underlying, protocol specific, connection.
| Method | __init__ | Constructor. |
| Method | clone | Return a new transport with root at self.base + offset |
| Method | relpath | Return the local path portion from a given absolute path |
| Method | abspath | Return the full url to the given relative path. |
| Method | disconnect | Disconnect the transport. |
| Method | _user | Undocumented |
| Method | _password | Undocumented |
| Method | _host | Undocumented |
| Method | _port | Undocumented |
| Method | _path | Undocumented |
| Method | _scheme | Undocumented |
| Static Method | _split_url | Undocumented |
| Static Method | _unsplit_url | Build the full URL for the given already URL encoded path. |
| Method | _remote_path | Return the absolute path part of the url to the given relative path. |
| Method | _get_shared_connection | Get the object shared amongst cloned transports. |
| Method | _set_connection | Record a newly created connection with its associated credentials. |
| Method | _get_connection | Returns the transport specific connection object. |
| Method | _get_credentials | Returns the credentials used to establish the connection. |
| Method | _update_credentials | Update the credentials of the current connection. |
| Method | _reuse_for | Returns a transport sharing the same connection if possible. |
Inherited from Transport:
| Method | create_prefix | Create all the directories leading down to self.base. |
| Method | ensure_base | Ensure that the directory this transport references exists. |
| Method | external_url | Return a URL for self that can be given to an external process. |
| Method | get_segment_parameters | Return the segment parameters for the top segment of the URL. |
| Method | recommended_page_size | Return the recommended page size for this transport. |
| Method | local_abspath | Return the absolute path on the local filesystem. |
| Method | has | Does the file relpath exist? |
| Method | has_multi | Return True/False for each entry in relpaths |
| Method | has_any | Return True if any of the paths exist. |
| Method | iter_files_recursive | Iter the relative paths of files in the transports sub-tree. |
| Method | get | Get the file at the given relative path. |
| Method | get_bytes | Get a raw string of the bytes for a file at the given location. |
| Method | get_smart_medium | Return a smart client medium for this transport if possible. |
| Method | readv | Get parts of the file at the given relative path. |
| Method | get_multi | Get a list of file-like objects, one for each entry in relpaths. |
| Method | put_bytes | Atomically put the supplied bytes into the given location. |
| Method | put_bytes_non_atomic | Copy the string into the target location. |
| Method | put_file | Copy the file-like object into the location. |
| Method | put_file_non_atomic | Copy the file-like object into the target location. |
| Method | mkdir | Create a directory at the given path. |
| Method | mkdir_multi | Create a group of directories |
| Method | open_write_stream | Open a writable file stream at relpath. |
| Method | append_file | Append bytes from a file-like object to a file at relpath. |
| Method | append_bytes | Append bytes to a file at relpath. |
| Method | append_multi | Append the text in each file-like or string object to |
| Method | copy | Copy the item at rel_from to the location at rel_to. |
| Method | copy_multi | Copy a bunch of entries. |
| Method | copy_to | Copy a set of entries from self into another Transport. |
| Method | copy_tree | Copy a subtree from one relpath to another. |
| Method | copy_tree_to_transport | Copy a subtree from one transport to another. |
| Method | rename | Rename a file or directory. |
| Method | move | Move the item at rel_from to the location at rel_to. |
| Method | move_multi | Move a bunch of entries. |
| Method | move_multi_to | Move a bunch of entries to a single location. |
| Method | delete | Delete the item at relpath |
| Method | delete_multi | Queue up a bunch of deletes to be done. |
| Method | delete_tree | Delete an entire tree. This may require a listable transport. |
| Method | __repr__ | Undocumented |
| Method | stat | Return the stat information for a file. |
| Method | rmdir | Remove a directory at the given path. |
| Method | stat_multi | Stat multiple files and return the information. |
| Method | readlink | Return a string representing the path to which the symbolic link points. |
| Method | hardlink | Create a hardlink pointing to source named link_name. |
| Method | symlink | Create a symlink pointing to source named link_name. |
| Method | listable | Return True if this store supports listing. |
| Method | list_dir | Return a list of all files at the given location. |
| Method | lock_read | Lock the given file for shared (read) access. |
| Method | lock_write | Lock the given file for exclusive (write) access. |
| Method | is_readonly | Return true if this connection cannot be written to. |
| Method | _translate_error | Translate an IOError or OSError into an appropriate bzr error. |
| Method | _pump | Most children will need to copy from one file-like |
| Method | _get_total | Try to figure out how many entries are in multi, |
| Method | _report_activity | Notify that this transport has activity. |
| Method | _update_pb | Update the progress bar based on the current count |
| Method | _iterate_over | Iterate over all entries in multi, passing them to func, |
| Method | _readv | Get parts of the file at the given relative path. |
| Method | _seek_and_read | An implementation of readv that uses fp.seek and fp.read. |
| Method | _sort_expand_and_combine | Helper for readv. |
| Static Method | _coalesce_offsets | Yield coalesced offsets. |
| Method | _can_roundtrip_unix_modebits | Return true if this transport can store and retrieve unix modebits. |
| Method | _redirected_to | Returns a transport suitable to re-issue a redirected request. |
The caller should ensure that _from_transport points at the same host as the new base.
| Parameters | base | transport root URL |
| _from_transport | optional transport to build from. The built transport will share the connection with this transport. |
We leave the daughter classes take advantage of the hint that it's a cloning not a raw creation.
user, password, host and path will be quoted if they contain reserved chars.
| Parameters | scheme | protocol |
| user | login | |
| password | associated password | |
| host | the server address | |
| port | the associated port | |
| path | the absolute path on the server | |
| Returns | The corresponding URL. | |
| Parameters | relpath | the relative path urlencoded |
| Returns | the Unicode version of the absolute path for relpath. | |
This is the path that the remote server expect to receive in the requests, daughter classes should redefine this method if needed and use the result to build their requests.
| Parameters | relpath | the path relative to the transport base urlencoded. |
| Returns | the absolute Unicode path on the server, | |
This should be used only by classes that needs to extend the sharing with objects other than transports.
Use _get_connection to get the connection itself.
Note: To ensure that connection is still shared after a temporary failure and a new one needs to be created, daughter classes should always call this method to set the connection and do so each time a new connection is created.
| Parameters | connection | An opaque object representing the connection used by the daughter class. |
| credentials | An opaque object representing the credentials needed to create the connection. |
Some protocols can renegociate the credentials within a connection, this method allows daughter classes to share updated credentials.
| Parameters | credentials | the updated credentials. |
Note: we share the connection if the expected credentials are the same: (host, port, user). Some protocols may disagree and redefine the criteria in daughter classes.
Note: we don't compare the passwords here because other_base may have been obtained from an existing transport.base which do not mention the password.
| Parameters | other_base | the URL we want to share the connection with. |
| Returns | A new transport or None if the connection cannot be shared. | |
If and when required the transport willl reconnect automatically.