diff options
author | jortel <devnull@localhost> | 2010-01-30 16:39:47 +0000 |
---|---|---|
committer | jortel <devnull@localhost> | 2010-01-30 16:39:47 +0000 |
commit | f11026be7465c1923d60c6e1fc5999abbfdecba3 (patch) | |
tree | a03a70acd7ef5ba3ec4d1fba7d0356030d09022c | |
parent | 041a3602a31024a8df50bc5962f351d473b4a782 (diff) | |
download | suds-f11026be7465c1923d60c6e1fc5999abbfdecba3.tar.gz |
Fix ticket #295 and raise specific exception when location not found in document store.
-rw-r--r-- | suds/__init__.py | 2 | ||||
-rw-r--r-- | suds/store.py | 33 |
2 files changed, 32 insertions, 3 deletions
diff --git a/suds/__init__.py b/suds/__init__.py index c600ed0..c3d788b 100644 --- a/suds/__init__.py +++ b/suds/__init__.py @@ -27,7 +27,7 @@ import sys # __version__ = '0.3.9' -__build__="(beta) R652-20100129" +__build__="(beta) R653-20100129" # # Exceptions diff --git a/suds/store.py b/suds/store.py index 2ec1917..85e0943 100644 --- a/suds/store.py +++ b/suds/store.py @@ -558,8 +558,37 @@ class DocumentStore: @return: A file pointer to the document. @rtype: StringIO """ - protocol, location = url.split('://', 1) + protocol, location = self.split(url) if protocol == self.protocol: - return StringIO(self.store[location]) + return self.find(location) else: return None + + def find(self, location): + """ + Find the specified location in the store. + @param location: The I{location} part of a URL. + @type location: str + @return: An input stream to the document. + @rtype: StringIO + """ + try: + content = self.store[location] + return StringIO(content) + except: + reason = 'location "%s" not in document store' % location + raise Exception, reason + + def split(self, url): + """ + Split the url into I{protocol} and I{location} + @param url: A URL. + @param url: str + @return: (I{url}, I{location}) + @rtype: tuple + """ + parts = url.split('://', 1) + if len(parts) == 2: + return parts + else: + return (None, url)
\ No newline at end of file |