diff options
author | Neha shah <shan.akshata@gmail.com> | 2012-05-30 15:25:06 +0530 |
---|---|---|
committer | Neha shah <shan.akshata@gmail.com> | 2012-05-30 15:25:06 +0530 |
commit | cc258419c26dca95a59aa1de8e11afa431f2aa2c (patch) | |
tree | 138c4fb609b138677429e8ee75598908a4261dd3 /gstudio/xmlrpc | |
parent | 721ada7e8f54952035a1c663dc09fd167e1eef29 (diff) | |
download | gnowsys-cc258419c26dca95a59aa1de8e11afa431f2aa2c.tar.gz |
get and set functions defined in metaweblog.py
Diffstat (limited to 'gstudio/xmlrpc')
-rw-r--r-- | gstudio/xmlrpc/__init__.py | 13 | ||||
-rw-r--r-- | gstudio/xmlrpc/metaweblog.py | 114 | ||||
-rw-r--r-- | gstudio/xmlrpc/rpc/views.py | 1 |
3 files changed, 126 insertions, 2 deletions
diff --git a/gstudio/xmlrpc/__init__.py b/gstudio/xmlrpc/__init__.py index dc767c6..beb1e72 100644 --- a/gstudio/xmlrpc/__init__.py +++ b/gstudio/xmlrpc/__init__.py @@ -111,7 +111,18 @@ GSTUDIO_XMLRPC_METAWEBLOG = [ 'metaWeblog.getlatestSSID'), ('gstudio.xmlrpc.metaweblog.getAllSnapshots', 'metaWeblog.getAllSnapshots'), - + ('gstudio.xmlrpc.metaweblog.setAttributetype', + 'metaWeblog.setAttributetype'), + ('gstudio.xmlrpc.metaweblog.setRelationtype', + 'metaWeblog.setRelationtype'), + ('gstudio.xmlrpc.metaweblog.setObjecttype', + 'metaWeblog.setObjecttype'), + ('gstudio.xmlrpc.metaweblog.setObject', + 'metaWeblog.setObject'), + ('gstudio.xmlrpc.metaweblog.setAttribute', + 'metaWeblog.setAttribute'), + ('gstudio.xmlrpc.metaweblog.setRelation', + 'metaWeblog.setRelation'), ('gstudio.xmlrpc.metaweblog.getGbobjectNeighbourhood', 'metaWeblog.getGbobjectNeighbourhood') diff --git a/gstudio/xmlrpc/metaweblog.py b/gstudio/xmlrpc/metaweblog.py index d44b018..ff40521 100644 --- a/gstudio/xmlrpc/metaweblog.py +++ b/gstudio/xmlrpc/metaweblog.py @@ -659,6 +659,120 @@ def getAllSnapshots(nid) : return n +@xmlrpc_func(returns='string', args=['struct','string']) +def setAttributetype(d,objid) : + + p = NID.objects.get(id = objid) + t = p.ref._meta.module_name + w = [] + if ( t == 'objecttype' or 'metatype') : + u = Attributetype.objects.filter(subjecttype_id = objid) + y = len(u) + r = 0 + for i in u : + if str(i.title) == d['title'] : + return "Attributetype:",d['title']," already exists" + else : + r = r + 1 + if r == y : + w = Attributetype(title = d['title'],applicable_nodetypes = d['nodetype'],subjecttype_id = objid,slug = d['slug']) + w.save() + return w.id + + + +@xmlrpc_func(returns='int', args=['struct','string']) + +def setRelationtype(d,uid) : + + + k = NID.objects.get(id = uid) + f = k.ref._meta.module_name + r = 0 + t = [] + if ( f == 'objecttype' or 'metatype') : + p = Relationtype.objects.filter(left_subjecttype_id = uid) + u = len(p) + for n in p : + if (str(n.title) == d['title']) : + return "Relationtype :",d['title'],"already exists for",n.title + else : + r = r + 1 + if r == u : + t = Relationtype(title = d['title'],left_subjecttype_id = uid,right_subjecttype_id = d['right_subjecttype_id'], + slug = d['slug'],inverse = d['inverse']) + t.save() + + return t.id + +@xmlrpc_func(returns='int', args=['struct','string']) + +def setObjecttype(d) : + + k = Objecttype.objects.all() + u = len(k) + r = 0 + t = [] + for n in k : + if (str(n.title) == d['title']) : + return "Objecttype",d['title'],"already exists" + else : + r = r + 1 + if r == u : + t = Objecttype(title = d['title'], slug = d['slug']) + t.save() + + return t.id + + +@xmlrpc_func(returns='int', args=['struct','string']) + +def setObject(d,o) : + + k = NID.objects.get(id = o) + t = k.ref._meta.module_name + u = 0 + r = 0 + y = [] + h = [] + if (t == 'objecttype' or t =='metatype') : + p = Objecttype.objects.get(id = o) + h = p.get_members + u = len(h) + for i in h : + if(str(i.title) == d['title']) : + return "Object",d['title'],"already exists for",p.title + else : + r = r + 1 + if r == u : + y = Gbobject(title = d['title'],slug = d['slug']) + y.save() + y.objecttypes.add(p) + return y.id + +@xmlrpc_func(returns='int', args=['struct','string']) + +def setAttribute(d,objid) : + + p = Attributetype.objects.filter(subjecttype_id = objid) + s = [] + for i in p : + if (str(i.title) == d['attributetype']) : + s = Attribute(attributetype_id = i.id,subject_id = d['subject_id'],svalue = d['svalue']) + s.save() + return s.id + +@xmlrpc_func(returns='int', args=['struct','string','string']) + +def setRelation(d,obj1,obj2) : + + p = Relationtype.objects.filter(left_subjecttype_id = obj1,right_subjecttype_id = obj2) + for i in p : + if (str(i.title) == d['relationtypename']) : + s = Relation(relationtype_id = i.id,left_subject_id = d['left_subject_id'],right_subject_id = d['right_subject_id']) + s.save() + return s.id + diff --git a/gstudio/xmlrpc/rpc/views.py b/gstudio/xmlrpc/rpc/views.py index 8b16bde..1edfa37 100644 --- a/gstudio/xmlrpc/rpc/views.py +++ b/gstudio/xmlrpc/rpc/views.py @@ -174,7 +174,6 @@ if hasattr(settings, 'XMLRPC_METHODS'): xmlrpcdispatcher.register_function(getlatestSSID,'getlatestSSID') xmlrpcdispatcher.register_function(getAllSnapshots,'getAllSnapshots') xmlrpcdispatcher.register_function(setAttributetype,'setAttributetype') - xmlrpcdispatcher.register_function(setuser,'setuser') xmlrpcdispatcher.register_function(setRelationtype,'setRelationtype') xmlrpcdispatcher.register_function(setObjecttype,'setObjecttype') xmlrpcdispatcher.register_function(setObject,'setObject') |