Skip to main content
Join the official 2019 Python Developers SurveyStart the survey!

Alfresco REST web services client library for python

Project description

A ligthweight python library based on the Alfresco RESTful web services.

Sample usage:

from alfREST import RESTHelper
path = "/Sites/mysite/documentLibrary/test"

# login
rh = RESTHelper()
rh.login(login, password, host, port)

# createDocument (sio could be a file object...)
from StringIO import StringIO
sio = StringIO()
sio.write("Well, that's all folks.") = "test.txt"
tkns = path.split("/")
siteId = tkns[2]
containerId = tkns[3]
uploadDirectory = "/".join(tkns[4:])
idObject = rh.fileUpload(sio, siteId, containerId, "/%s" % uploadDirectory)

# get properties
props = rh.getProperties("%s/test.txt" % path)
assert props["cmis:createdBy"] == login

# get content
content = rh.getContent("%s/test.txt" % path)
assert content == "Well, that's all folks."

# add a tag to the document
rh.addTag("workspace", "SpacesStore", idObject, "tag_test")
assert "tag_test" in rh.getNodeTags("workspace", "SpacesStore", idObject)

# list document in folder
children = rh.getChildren(path)
assert children[0]["cmis:name"] == "test.txt"

# create a group and apply a  policy to the test folder
acl = {}
acl[u'GROUP_TEST'] = [([u"{}cmobject.Consumer",], True),]
rh.applyACL(path, acl)

# create a new user, insert the user in the group
rh.addPerson("supermario", "mario", "super", "", "imsuper")
rh.addGroupOrUserToGroup(u"supermario", u"GROUP_TEST")

# some check
users = rh.listChildAuthorities(u"GROUP_TEST")
assert len(users) == 1
assert users[0]['fullName'] == "supermario"

# restore initial status
rh.removeAuthorityFromGroup(u"supermario", u"GROUP_TEST")
acl = {}
rh.applyACL(path, acl)

# remove tag from the file object
rh.deleteTag("workspace", "SpacesStore", idObject, "tag_test")
assert "tag_test" not in rh.getNodeTags("workspace", "SpacesStore", idObject)

# delete the file object

# logout

Changelogs 0.9.3

  • addTag
  • deleteTag

Changelogs 0.9.2c (bugfix: upload binary files works)

  • createFolder
  • getNodeTags (get all the tags for a node)

Changelogs 0.9.1

  • upload (upload file content and meta-data into repository)
  • delete file (delete the specified object)
  • getChildren (gets the list of child objects contained in the specified folder)
  • getContent (gets the content stream for the specified document)
  • getProperties (gets the properties for the object)

Road to 1.0

  • Create / Move a Folder or Document (createDocument, createFolder, createPolicy, moveObject)
  • Write Content (setContent)
  • Delete Content (deleteContent)
  • Get Content (getContent)
  • Get Folder Children (getChildren)

Road to 1.1

  • Get Checked Out Documents (getCheckedOutDocs)
  • Checkout Document (checkOut)
  • Cancel Checkout (cancelCheckout)
  • Checkin Private Working Copy (checkin)


For more info and requests: tiziano [at]

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for alfREST, version 0.9.3
Filename, size File type Python version Upload date Hashes
Filename, size alfREST-0.9.3b.tar.gz (21.0 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page