~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/smart/request.py

  • Committer: Andrew Bennetts
  • Date: 2009-03-18 04:49:31 UTC
  • mto: This revision was merged to the branch mainline in revision 4194.
  • Revision ID: andrew.bennetts@canonical.com-20090318044931-uqq32ujozbz0csuv
Add setup_jail and teardown_jail to SmartServerRequest.

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
"""
28
28
 
29
29
import tempfile
 
30
import threading
30
31
 
31
32
from bzrlib import (
32
33
    bzrdir,
42
43
""")
43
44
 
44
45
 
 
46
jail_info = threading.local()
 
47
jail_info.transports = None
 
48
 
 
49
 
45
50
class SmartServerRequest(object):
46
51
    """Base class for request handlers.
47
52
 
121
126
        self._body_chunks = None
122
127
        return self.do_body(body_bytes)
123
128
 
 
129
    def setup_jail(self):
 
130
        jail_info.transports = [self._backing_transport]
 
131
 
 
132
    def teardown_jail(self):
 
133
        jail_info.transports = None
 
134
 
124
135
    def translate_client_path(self, client_path):
125
136
        """Translate a path received from a network client into a local
126
137
        relpath.
277
288
        # XXX: most of this error conversion is VFS-related, and thus ought to
278
289
        # be in SmartServerVFSRequestHandler somewhere.
279
290
        try:
280
 
            return callable(*args, **kwargs)
 
291
            self._command.setup_jail()
 
292
            try:
 
293
                return callable(*args, **kwargs)
 
294
            finally:
 
295
                self._command.teardown_jail()
281
296
        except (KeyboardInterrupt, SystemExit):
282
297
            raise
283
298
        except Exception, err: