Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/tutorius
diff options
context:
space:
mode:
Diffstat (limited to 'tutorius')
-rw-r--r--tutorius/apilib/__init__.pycbin105 -> 105 bytes
-rw-r--r--tutorius/apilib/httplib2/__init__.pycbin43223 -> 39750 bytes
-rw-r--r--tutorius/apilib/httplib2/iri2uri.pycbin3920 -> 3674 bytes
-rw-r--r--tutorius/apilib/mimeTypes.pycbin2249 -> 2249 bytes
-rw-r--r--tutorius/apilib/restful_lib.pycbin4972 -> 4972 bytes
-rw-r--r--tutorius/store.py78
6 files changed, 52 insertions, 26 deletions
diff --git a/tutorius/apilib/__init__.pyc b/tutorius/apilib/__init__.pyc
index 5ccf259..bd4346b 100644
--- a/tutorius/apilib/__init__.pyc
+++ b/tutorius/apilib/__init__.pyc
Binary files differ
diff --git a/tutorius/apilib/httplib2/__init__.pyc b/tutorius/apilib/httplib2/__init__.pyc
index f4d8036..e5f8ebe 100644
--- a/tutorius/apilib/httplib2/__init__.pyc
+++ b/tutorius/apilib/httplib2/__init__.pyc
Binary files differ
diff --git a/tutorius/apilib/httplib2/iri2uri.pyc b/tutorius/apilib/httplib2/iri2uri.pyc
index 670ac45..879e719 100644
--- a/tutorius/apilib/httplib2/iri2uri.pyc
+++ b/tutorius/apilib/httplib2/iri2uri.pyc
Binary files differ
diff --git a/tutorius/apilib/mimeTypes.pyc b/tutorius/apilib/mimeTypes.pyc
index e9bd261..35ef2b2 100644
--- a/tutorius/apilib/mimeTypes.pyc
+++ b/tutorius/apilib/mimeTypes.pyc
Binary files differ
diff --git a/tutorius/apilib/restful_lib.pyc b/tutorius/apilib/restful_lib.pyc
index 9cf5277..5b06765 100644
--- a/tutorius/apilib/restful_lib.pyc
+++ b/tutorius/apilib/restful_lib.pyc
Binary files differ
diff --git a/tutorius/store.py b/tutorius/store.py
index 9c57ce9..d678729 100644
--- a/tutorius/store.py
+++ b/tutorius/store.py
@@ -18,6 +18,7 @@ import urllib
import urllib2
from xml.dom import minidom
from apilib.restful_lib import Connection
+from array import array
class StoreProxy(object):
"""
@@ -27,14 +28,14 @@ class StoreProxy(object):
"""
def __init__(self):
-
+
# Base Urls for the api
- self.base_url = "http://tutorius.dev/en-US/tutorius"
+ self.base_url = "http://bobthebuilder.mine.nu/tutorius/en-US/tutorius"
self.remora_api = "api/1.4"
self.tutorius_api = "TutoriusApi"
self.bandwagon_api = "api/1.4/sharing"
- self.api_auth_key = ""
+ self.api_auth_key = None
# Prepares the connection with the api
self.conn = Connection(self.base_url)
@@ -67,22 +68,48 @@ class StoreProxy(object):
# Loop through the categories and create the list to be returned
for xml_category in xml_categories:
category = {}
-
+
category['id'] = xml_category.getElementsByTagName('id')[0].firstChild.nodeValue
category['name'] = xml_category.getElementsByTagName('name')[0].firstChild.nodeValue
categories.append(category)
return categories
+
+ def search(self, keywords, category='all', page=1, numResults=10, sortBy='name'):
+ """
+ Returns a list of tutorials that correspond to the given search criteria.
+
+ @param keywords The keywords to search for
+ @param page The page in the result set from which to return results. This is
+ used to allow applications to fetch results one set at a time.
+ @param numResults The max number of results that can be returned in a page
+ @param sortBy The field on which to sort the results
+ @return A list of tutorial meta-data that corresponds to the query
+ """
+ request_url = "/%s/search/%s/%s/%d/%d/%s" % (self.tutorius_api, keywords, category, page, numResults, sortBy)
+
+ response = self.conn.request_get(request_url)
+
+ if (self.helper.iserror(response)):
+ return False
+
+ xml_response = minidom.parseString(response['body'])
+
+ xml_tutorials = xml_response.getElementsByTagName('tutorial')
+
+ tutorials = list()
+
+ for xml_tutorial in xml_tutorials:
+ tutorial = self.helper.parse_tutorial(xml_tutorial)
+ tutorials.append(tutorial)
+ return tutorials
def get_tutorials(self, category='all', page=1, numResults=10, sortBy='name'):
"""
Returns the list of tutorials that correspond to the given search criteria.
- @param keywords The list of keywords that should be matched inside the tutorial title
- or description. If None, the search will not filter the results
- according to the keywords.
@param category The category in which to restrict the search.
@param page The page in the result set from which to return results. This is
used to allow applications to fetch results one set at a time.
@@ -138,17 +165,6 @@ class StoreProxy(object):
return tutorials
- def get_tutorial_collection(self, collection_name):
- """
- Returns a list of tutorials corresponding to the given collection name.
- Collections can be groups like '5 most downloaded' or 'Top 10 ratings'.
-
- @param collection_name The name of the collection from which we want the
- meta-data
- @return A list of tutorial meta-data corresponding to the given group
- """
- raise NotImplementedError("get_tutorial_collection() not implemented... yet!")
-
def get_latest_version(self, tutorial_id_list):
"""
Returns the latest version number on the server, for each tutorial ID
@@ -325,7 +341,7 @@ class StoreProxy(object):
return True
-
+
def unpublish(self, tutorial_store_id):
"""
Removes a tutorial from the server. The user in the current session
@@ -433,12 +449,22 @@ class StoreProxyHelper(object):
@return A dictionnary containing the metadata
"""
tutorial = {}
-
- tutorial['name'] = xml_tutorial.getElementsByTagName('name')[0].firstChild.nodeValue
- tutorial['summary'] = xml_tutorial.getElementsByTagName('summary')[0].firstChild.nodeValue
- tutorial['version'] = xml_tutorial.getElementsByTagName('version')[0].firstChild.nodeValue
- tutorial['description'] =""
- tutorial['author'] = ""
- tutorial['rating'] = ""
+
+ params = [
+ 'name',
+ 'summary',
+ 'version',
+ 'description',
+ 'author',
+ 'rating'
+ ]
+
+ for param in params:
+ xml_node = xml_tutorial.getElementsByTagName(param)[0].firstChild
+
+ if xml_node != None:
+ tutorial[param] = xml_node.nodeValue
+ else:
+ tutorial[param] = ''
return tutorial \ No newline at end of file