~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/smart/request.py

  • Committer: Andrew Bennetts
  • Date: 2007-12-13 22:22:58 UTC
  • mto: This revision was merged to the branch mainline in revision 3320.
  • Revision ID: andrew.bennetts@canonical.com-20071213222258-mh7mq5gtxqn4yceb
All WSGI tests passing, and manual testing works too.

Show diffs side-by-side

added added

removed removed

Lines of Context:
51
51
            from the client.  Clients will not be able to refer to paths above
52
52
            this root.
53
53
        """
54
 
        rcp = root_client_path
55
54
        self._backing_transport = backing_transport
56
 
        if not root_client_path.startswith('/'):
57
 
            root_client_path = '/' + root_client_path
58
 
        if not root_client_path.endswith('/'):
59
 
            root_client_path += '/'
 
55
        if root_client_path is not None:
 
56
            if not root_client_path.startswith('/'):
 
57
                root_client_path = '/' + root_client_path
 
58
            if not root_client_path.endswith('/'):
 
59
                root_client_path += '/'
60
60
        self._root_client_path = root_client_path
61
61
 
62
62
    def _check_enabled(self):
101
101
 
102
102
        All paths received from the client *must* be translated.
103
103
 
 
104
        :param client_path: the path from the client.
104
105
        :returns: a relpath that may be used with self._backing_transport
 
106
            (unlike the untranslated client_path, which must not be used with
 
107
            the backing transport).
105
108
        """
 
109
        if self._root_client_path is None:
 
110
            # no translation necessary!
 
111
            return client_path
106
112
        if not client_path.startswith('/'):
107
113
            client_path = '/' + client_path
108
114
        if client_path.startswith(self._root_client_path):
109
115
            path = client_path[len(self._root_client_path):]
110
116
            relpath = urlutils.joinpath('/', path)
111
117
            assert relpath.startswith('/')
 
118
            mutter('translate_client_path(%r) [rcp=%r, backing=%r] -> %r',
 
119
                client_path, self._root_client_path, self._backing_transport,
 
120
                '.' + relpath)
112
121
            return '.' + relpath
113
122
        else:
114
123
            raise errors.PathNotChild(client_path, self._root_client_path)
121
130
        :returns: a transport cloned from self._backing_transport
122
131
        """
123
132
        relpath = self.translate_client_path(client_path)
124
 
        return self._backing_transport.clone(relpath)
 
133
        result = self._backing_transport.clone(relpath)
 
134
        mutter('transport_from_client_path -> %r', result)
 
135
        return result
125
136
 
126
137
 
127
138
class SmartServerResponse(object):