diff options
author | ben <ben@tutorius-dev.(none)> | 2009-11-02 19:23:15 (GMT) |
---|---|---|
committer | ben <ben@tutorius-dev.(none)> | 2009-11-02 19:23:15 (GMT) |
commit | 86511b28a7949a548213fb7d1cbbb6126208965e (patch) | |
tree | 8fadf7107e8ee101ba58a889ebb46ce7f1bc66b8 /tutorius | |
parent | 77671f444acb640ac19ac8f7f21771d216352879 (diff) |
final version of the StoreProxy and its tests
Diffstat (limited to 'tutorius')
-rw-r--r-- | tutorius/store.py | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/tutorius/store.py b/tutorius/store.py index d678729..760daec 100644 --- a/tutorius/store.py +++ b/tutorius/store.py @@ -27,10 +27,10 @@ class StoreProxy(object): shop to implement all the requests that could be made to the Store. """ - def __init__(self): + def __init__(self, base_url): # Base Urls for the api - self.base_url = "http://bobthebuilder.mine.nu/tutorius/en-US/tutorius" + self.base_url = base_url self.remora_api = "api/1.4" self.tutorius_api = "TutoriusApi" self.bandwagon_api = "api/1.4/sharing" @@ -50,14 +50,13 @@ class StoreProxy(object): @return The list of category names stored on the server. """ - categories = {} request_url = "/%s/categories" % (self.tutorius_api) response = self.conn.request_get(request_url) if self.helper.iserror(response): - return categories + return None xml_response = minidom.parseString(response['body']) @@ -92,7 +91,7 @@ class StoreProxy(object): response = self.conn.request_get(request_url) if (self.helper.iserror(response)): - return False + return None xml_response = minidom.parseString(response['body']) @@ -123,7 +122,7 @@ class StoreProxy(object): response = self.conn.request_get(request_url) if (self.helper.iserror(response)): - return False + return None xml_response = minidom.parseString(response['body']) @@ -150,7 +149,7 @@ class StoreProxy(object): response = self.conn.request_get(request_url) if (self.helper.iserror(response)): - return False + return None xml_response = minidom.parseString(response['body']) @@ -184,6 +183,9 @@ class StoreProxy(object): response = self.conn.request_get(request_url) + if (self.helper.iserror(response)): + return None + xml = minidom.parseString(response['body']) versionnode = xml.getElementsByTagName("version")[0] @@ -211,7 +213,7 @@ class StoreProxy(object): response = self.conn.request_get(request_url) if (self.helper.iserror(response)): - return False + return None xml = minidom.parseString(response['body']) @@ -267,7 +269,7 @@ class StoreProxy(object): if (self.helper.iserror(response)): return False - self.api_auth_key = "" + self.api_auth_key = None return True @@ -316,10 +318,11 @@ class StoreProxy(object): """ # This is in the case we have to re-publish a tutorial - if tutorial_store_id != None: + if tutorial_store_id is not None: request_url = "/%s/publish/%s" % (self.tutorius_api, tutorial_store_id) + headers = { 'X-API-Auth' : self.api_auth_key } - response = self.conn.request_post(request_url) + response = self.conn.request_post(request_url, None, None, None, headers) if self.helper.iserror(response): return False |