~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/smart/medium.py

  • Committer: Andrew Bennetts
  • Date: 2008-05-20 00:42:19 UTC
  • mto: This revision was merged to the branch mainline in revision 3439.
  • Revision ID: andrew.bennetts@canonical.com-20080520004219-11umu8ynx5c39bqg
Push remote_path_from_transport logic into SmartClientMedium, removing special-casing of bzr+http from _SmartClient.

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
import os
28
28
import socket
29
29
import sys
 
30
import urllib
30
31
 
31
32
from bzrlib import (
32
33
    errors,
33
34
    osutils,
34
35
    symbol_versioning,
 
36
    urlutils,
35
37
    )
36
38
from bzrlib.smart.protocol import (
37
39
    MESSAGE_VERSION_THREE,
479
481
        The default implementation does nothing.
480
482
        """
481
483
        
 
484
    def remote_path_from_transport(self, transport):
 
485
        """Convert transport into a path suitable for using in a request.
 
486
        
 
487
        Note that the resulting remote path doesn't encode the host name or
 
488
        anything but path, so it is only safe to use it in requests sent over
 
489
        the medium from the matching transport.
 
490
        """
 
491
        medium_base = urlutils.join(self.base, '/')
 
492
        rel_url = urlutils.relative_url(medium_base, transport.base)
 
493
        return urllib.unquote(rel_url)
 
494
 
482
495
 
483
496
class SmartClientStreamMedium(SmartClientMedium):
484
497
    """Stream based medium common class.