~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/transport/http/__init__.py

  • Committer: John Arbash Meinel
  • Date: 2006-09-05 23:09:22 UTC
  • mfrom: (1955.3.26 transport_bytes)
  • mto: This revision was merged to the branch mainline in revision 1989.
  • Revision ID: john@arbash-meinel.com-20060905230922-6ed11ce0a4b04065
[merge] transport_bytes: bring knit churn up-to-date with new *{bytes,file} functions

Show diffs side-by-side

added added

removed removed

Lines of Context:
170
170
            # TODO: Don't call this with an array - no magic interfaces
171
171
            relpath_parts = relpath[:]
172
172
        if len(relpath_parts) > 1:
 
173
            # TODO: Check that the "within branch" part of the
 
174
            # error messages below is relevant in all contexts
173
175
            if relpath_parts[0] == '':
174
176
                raise ValueError("path %r within branch %r seems to be absolute"
175
177
                                 % (relpath, self._path))
176
 
            if relpath_parts[-1] == '':
 
178
            # read only transports never manipulate directories
 
179
            if self.is_readonly() and relpath_parts[-1] == '':
177
180
                raise ValueError("path %r within branch %r seems to be a directory"
178
181
                                 % (relpath, self._path))
179
182
        basepath = self._path.split('/')
281
284
 
282
285
        return combined
283
286
 
284
 
    def put(self, relpath, f, mode=None):
285
 
        """Copy the file-like or string object into the location.
 
287
    def put_file(self, relpath, f, mode=None):
 
288
        """Copy the file-like object into the location.
286
289
 
287
290
        :param relpath: Location to put the contents, relative to base.
288
 
        :param f:       File-like or string object.
 
291
        :param f:       File-like object.
289
292
        """
290
293
        raise TransportNotPossible('http PUT not supported')
291
294
 
297
300
        """See Transport.rmdir."""
298
301
        raise TransportNotPossible('http does not support rmdir()')
299
302
 
300
 
    def append(self, relpath, f):
 
303
    def append_file(self, relpath, f, mode=None):
301
304
        """Append the text in the file-like object into the final
302
305
        location.
303
306
        """
494
497
    # used to form the url that connects to this server
495
498
    _url_protocol = 'http'
496
499
 
 
500
    # Subclasses can provide a specific request handler
 
501
    def __init__(self, request_handler=TestingHTTPRequestHandler):
 
502
        Server.__init__(self)
 
503
        self.request_handler = request_handler
 
504
 
497
505
    def _http_start(self):
498
506
        httpd = None
499
507
        httpd = TestingHTTPServer(('localhost', 0),
500
 
                                  TestingHTTPRequestHandler,
 
508
                                  self.request_handler,
501
509
                                  self)
502
510
        host, port = httpd.socket.getsockname()
503
511
        self._http_base_url = '%s://localhost:%s/' % (self._url_protocol, port)
558
566
        
559
567
    def get_bogus_url(self):
560
568
        """See bzrlib.transport.Server.get_bogus_url."""
561
 
        # this is chosen to try to prevent trouble with proxies, wierd dns,
 
569
        # this is chosen to try to prevent trouble with proxies, weird dns,
562
570
        # etc
563
571
        return 'http://127.0.0.1:1/'
564
572