~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/smart/client.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2008-01-15 00:34:05 UTC
  • mfrom: (3104.4.7 bzr-http-client)
  • Revision ID: pqm@pqm.ubuntu.com-20080115003405-jfuumkpctmvl2e4r
(andrew) Calculate remote path relative to the shared medium in
        _SmartClient.

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
from urlparse import urlparse
18
18
 
19
19
from bzrlib.smart import protocol
20
 
from bzrlib.urlutils import unescape
 
20
from bzrlib import urlutils
21
21
 
22
22
 
23
23
class _SmartClient(object):
24
24
 
25
 
    def __init__(self, shared_medium):
26
 
        self._shared_medium = shared_medium
 
25
    def __init__(self, shared_connection):
 
26
        """Constructor.
 
27
 
 
28
        :param shared_connection: a bzrlib.transport._SharedConnection
 
29
        """
 
30
        self._shared_connection = shared_connection
27
31
 
28
32
    def get_smart_medium(self):
29
 
        return self._shared_medium.connection
 
33
        return self._shared_connection.connection
30
34
 
31
35
    def call(self, method, *args):
32
36
        """Call a method on the remote server."""
68
72
        anything but path, so it is only safe to use it in requests sent over
69
73
        the medium from the matching transport.
70
74
        """
71
 
        return unescape(urlparse(transport.base)[2]).encode('utf8')
 
75
        if self._shared_connection.base.startswith('bzr+http://'):
 
76
            medium_base = self._shared_connection.base
 
77
        else:
 
78
            medium_base = urlutils.join(self._shared_connection.base, '/')
 
79
            
 
80
        return urlutils.relative_url(medium_base, transport.base).encode('utf8')