diff options
author | Johnson Chetty <johnsonchetty@gmail.com> | 2012-03-22 08:19:12 +0000 |
---|---|---|
committer | Johnson Chetty <johnsonchetty@gmail.com> | 2012-03-22 08:19:12 +0000 |
commit | 1cb48d5e6346e9a319af1942bc5a09add3bf4ed9 (patch) | |
tree | 126f84a8a9423269f9896dc639019ad0490f655e /gstudio/xmlrpc | |
parent | 22c5770af6ac84f03315061f1b4c174528453c51 (diff) | |
download | gnowsys-1cb48d5e6346e9a319af1942bc5a09add3bf4ed9.tar.gz |
xmlrpc get_nbh for OT, O, MT .. rudimendtary work
Diffstat (limited to 'gstudio/xmlrpc')
-rw-r--r-- | gstudio/xmlrpc/__init__.py | 4 | ||||
-rw-r--r-- | gstudio/xmlrpc/metaweblog.py | 32 |
2 files changed, 36 insertions, 0 deletions
diff --git a/gstudio/xmlrpc/__init__.py b/gstudio/xmlrpc/__init__.py index 88ced6b..9bec595 100644 --- a/gstudio/xmlrpc/__init__.py +++ b/gstudio/xmlrpc/__init__.py @@ -75,6 +75,10 @@ GSTUDIO_XMLRPC_METAWEBLOG = [ 'metaWeblog.newPost'), ('gstudio.xmlrpc.metaweblog.edit_post', 'metaWeblog.editPost'), + ('gstudio.xmlrpc.metaweblog.add_nums', + 'metaWeblog.add_nums'), + ('gstudio.xmlrpc.metaweblog.get_nbh', + 'metaWeblog.get_nbh'), ('gstudio.xmlrpc.metaweblog.new_media_object', 'metaWeblog.newMediaObject')] diff --git a/gstudio/xmlrpc/metaweblog.py b/gstudio/xmlrpc/metaweblog.py index 56ee26c..6c89c21 100644 --- a/gstudio/xmlrpc/metaweblog.py +++ b/gstudio/xmlrpc/metaweblog.py @@ -64,6 +64,8 @@ from django.template.defaultfilters import slugify from gstudio.models import Nodetype from gstudio.models import Metatype +from gstudio.models import NID +from objectapp.models import Gbobject from gstudio.settings import PROTOCOL from gstudio.settings import UPLOAD_TO from gstudio.managers import DRAFT, PUBLISHED @@ -246,6 +248,36 @@ def new_metatype(blog_id, username, password, metatype_struct): return metatype.pk +@xmlrpc_func(returns='struct', args=['string', 'string']) +def add_nums(num1, num2): + """metaWeblog.add("num1","num2") + => sum""" + num1= int(num1) + num2= int(num2) + return dict({'sum':[num1 + num2]}) + +@xmlrpc_func(returns='string', args=['string', 'string']) +def get_nbh(name, of_type=""): + """metaWeblog.get_nbh("object_name", "type of: [OT, O, MT]") + => nbh""" + # this should be extended to identifying an object with other criteria instead of title as it can be ambiguous + try: + # retrieve the first matching object, (this should be changed to id or an additional specifiers like of_type="OT") + n = NID.objects.filter(title=name)[0] + if not n: + return str({'error':'NOT FOUND'}) + + if n.ref._meta.module_name == 'objecttype' or 'gbobject' or 'metatype': + nbh = n.ref.get_nbh + if nbh: + return str(nbh) + else: + return str({'error':'Error!'}) + else: + return str({'error':'Not applicable as node is not OT, O or MT'}) + except: + return str({'error':'Error!'}) + @xmlrpc_func(returns='string', args=['string', 'string', 'string', 'struct', 'boolean']) def new_post(blog_id, username, password, post, publish): |