~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/smart/request.py

Setting NO_SMART_VFS in environment will disable VFS methods in the smart server. (Robert Collins, John Arbash Meinel, Andrew Bennetts)

Show diffs side-by-side

added added

removed removed

Lines of Context:
30
30
    def __init__(self, backing_transport):
31
31
        self._backing_transport = backing_transport
32
32
 
 
33
    def _check_enabled(self):
 
34
        """Raises DisabledMethod if this method is disabled."""
 
35
        pass
 
36
 
33
37
    def do(self, *args):
34
 
        """Called with the arguments of the request.
 
38
        """Mandatory extension point for SmartServerRequest subclasses.
 
39
        
 
40
        Subclasses must implement this.
35
41
        
36
42
        This should return a SmartServerResponse if this command expects to
37
43
        receive no body.
38
44
        """
39
45
        raise NotImplementedError(self.do)
40
46
 
 
47
    def execute(self, *args):
 
48
        """Public entry point to execute this request.
 
49
 
 
50
        It will return a SmartServerResponse if the command does not expect a
 
51
        body.
 
52
 
 
53
        :param *args: the arguments of the request.
 
54
        """
 
55
        self._check_enabled()
 
56
        return self.do(*args)
 
57
 
41
58
    def do_body(self, body_bytes):
42
59
        """Called if the client sends a body with the request.
43
60
        
113
130
        except LookupError:
114
131
            raise errors.SmartProtocolError("bad request %r" % (cmd,))
115
132
        self._command = command(self._backing_transport)
116
 
        self._run_handler_code(self._command.do, args, {})
 
133
        self._run_handler_code(self._command.execute, args, {})
117
134
 
118
135
    def _run_handler_code(self, callable, args, kwargs):
119
136
        """Run some handler specific code 'callable'.