Skip to content

Instantly share code, notes, and snippets.

@level09
Forked from anarchivist/gist:263281
Created December 22, 2011 15:06
Show Gist options
  • Save level09/1510613 to your computer and use it in GitHub Desktop.
Save level09/1510613 to your computer and use it in GitHub Desktop.
Accessing Drupal's XMLRPC/Services API from Python
# probably ripped off from somewhere on drupal.org
# requires the services module
import xmlrpclib
s = xmlrpclib.ServerProxy('http://localhost/services/xmlrpc')
class DrupalNode:
def __init__(self, title, body, path, ntype='page', uid=1, username='mmatienzo'):
self.title = title
self.body = body
self.path = path
self.type = ntype
self.uid = uid
self.nid = 67
self.name = username
self.promote = True
self.taxonomy = {'3': '3'} #how do i create new taxonomy terms???
try:
sessid, user = s.system.connect()
n = DrupalNode('ZA WARUDO!', 'toki wo tomare', 'saworhhhjjjdss')
s.node.save('roadroallerdawryyy', n)
except xmlrpclib.Fault, err:
print "A fault occurred"
print "Fault code: %d" % err.faultCode
print "Fault string: %s" % err.faultString
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment