~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/transport/smart/request.py

Add docstrings to all the new modules, and a few other places.

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
# along with this program; if not, write to the Free Software
15
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16
16
 
 
17
"""Basic server-side logic for dealing with requests."""
 
18
 
 
19
 
17
20
import tempfile
18
21
 
19
22
from bzrlib import bzrdir, errors, revision
22
25
 
23
26
class SmartServerRequest(object):
24
27
    """Base class for request handlers.
25
 
 
26
 
    (Command pattern.)
27
28
    """
28
29
 
29
30
    def __init__(self, backing_transport):
30
31
        self._backing_transport = backing_transport
31
32
 
32
 
    def do(self):
 
33
    def do(self, *args):
 
34
        """Called with the arguments of the request.
 
35
        
 
36
        This should return a SmartServerResponse if this command expects to
 
37
        receive no body.
 
38
        """
33
39
        raise NotImplementedError(self.do)
34
40
 
35
41
    def do_body(self, body_bytes):
 
42
        """Called if the client sends a body with the request.
 
43
        
 
44
        Must return a SmartServerResponse.
 
45
        """
 
46
        # TODO: if a client erroneously sends a request that shouldn't have a
 
47
        # body, what to do?  Probably SmartServerRequestHandler should catch
 
48
        # this NotImplementedError and translate it into a 'bad request' error
 
49
        # to send to the client.
36
50
        raise NotImplementedError(self.do_body)
37
51
 
38
52
 
110
124
        from them.
111
125
        """
112
126
        result = self._call_converting_errors(callable, args, kwargs)
 
127
 
113
128
        if result is not None:
114
129
            self.response = result
115
130
            self.finished_reading = True