~benji/lazr.restfulclient/fix-test-failures

« back to all changes in this revision

Viewing changes to src/lazr/restfulclient/resource.py

  • Committer: Leonard Richardson
  • Date: 2010-06-25 15:50:38 UTC
  • mfrom: (101.1.2 load-relative-uri)
  • Revision ID: leonard.richardson@canonical.com-20100625155038-8d5cmbz1dqne9dh2
Tags: 0.9.20
Make load() support relative URIs.

Show diffs side-by-side

added added

removed removed

Lines of Context:
450
450
 
451
451
    def load(self, url):
452
452
        """Load a resource given its URL."""
 
453
        parsed = urlparse(url)
 
454
        if parsed.scheme == '':
 
455
            # This is a relative URL. Make it absolute by joining
 
456
            # it with the service root resource.
 
457
            if url[:1] == '/':
 
458
                url = url[1:]
 
459
            url = self._root_uri.append(url)
453
460
        document = self._browser.get(url)
454
461
        try:
455
462
            representation = simplejson.loads(unicode(document))