Code

The cmislib.model Module

The cmislib.model Module contains all the CMIS domain objects. When working with the repository, the first thing you need to do is grab an instance of cmislib.model.CmisClient, passing it the repository endpoint URL, username, and password.

>>> cmisClient = CmisClient('http://localhost:8080/alfresco/s/cmis', 'admin', 'admin')

From there you can get the default repository...

>>> repo = cmisClient.defaultRepository

or a specific repository if you know the repository ID.

>>> repo = cmisClient.getRepository('83beb297-a6fa-4ac5-844b-98c871c0eea9')

Once you have that, you’re off to the races. Use the cmislib.model.Repository class to create new cmislib.model.Folder and cmislib.model.Document objects, perform searches, etc.

Module containing the domain objects used to work with a CMIS provider.

class cmislib.model.ACE(principalId=None, permissions=None, direct=None)

Represents an individual Access Control Entry.

direct
Getter for direct
permissions
Getter for permissions
principalId
Getter for principalId
class cmislib.model.ACL(aceList=None, xmlDoc=None)

Represents the Access Control List for an object.

addEntry(ace)

Adds an ACE entry to the ACL.

>>> acl = folder.getACL()
>>> acl.addEntry(ACE('jpotts', 'cmis:read', 'true'))
>>> acl.addEntry(ACE('jsmith', 'cmis:write', 'true'))
>>> acl.getEntries()
{u'GROUP_EVERYONE': <cmislib.model.ACE object at 0x100731410>, u'jdoe': <cmislib.model.ACE object at 0x100731150>, 'jpotts': <cmislib.model.ACE object at 0x1005a22d0>, 'jsmith': <cmislib.model.ACE object at 0x1005a2210>}
clearEntries()

Clears all ACE entries from the ACL and removes the internal XML representation of the ACL.

>>> acl = ACL()
>>> acl.addEntry(ACE('jsmith', 'cmis:write', 'true'))
>>> acl.addEntry(ACE('jpotts', 'cmis:write', 'true'))
>>> acl.entries
{'jpotts': <cmislib.model.ACE object at 0x1012c7310>, 'jsmith': <cmislib.model.ACE object at 0x100528490>}
>>> acl.getXmlDoc()
<xml.dom.minidom.Document instance at 0x1012cbb90>
>>> acl.clearEntries()
>>> acl.entries
>>> acl.getXmlDoc()
entries

Returns a dictionary of ACE objects for each Access Control Entry in the ACL. The key value is the ACE principalid.

>>> acl = ACL()
>>> acl.addEntry(ACE('jsmith', 'cmis:write', 'true'))
>>> acl.addEntry(ACE('jpotts', 'cmis:write', 'true'))
>>> for ace in acl.entries.values():
...     print 'principal:%s has the following permissions...' % ace.principalId
...     for perm in ace.permissions:
...             print perm
...
principal:jpotts has the following permissions...
cmis:write
principal:jsmith has the following permissions...
cmis:write
getEntries()

Returns a dictionary of ACE objects for each Access Control Entry in the ACL. The key value is the ACE principalid.

>>> acl = ACL()
>>> acl.addEntry(ACE('jsmith', 'cmis:write', 'true'))
>>> acl.addEntry(ACE('jpotts', 'cmis:write', 'true'))
>>> for ace in acl.entries.values():
...     print 'principal:%s has the following permissions...' % ace.principalId
...     for perm in ace.permissions:
...             print perm
...
principal:jpotts has the following permissions...
cmis:write
principal:jsmith has the following permissions...
cmis:write
getXmlDoc()
This method rebuilds the local XML representation of the ACL based on the ACE objects in the entries list and returns the resulting XML Document.
removeEntry(principalId)

Removes the ACE entry given a specific principalId.

>>> acl.getEntries()
{u'GROUP_EVERYONE': <cmislib.model.ACE object at 0x100731410>, u'jdoe': <cmislib.model.ACE object at 0x100731150>, 'jpotts': <cmislib.model.ACE object at 0x1005a22d0>, 'jsmith': <cmislib.model.ACE object at 0x1005a2210>}
>>> acl.removeEntry('jsmith')
>>> acl.getEntries()
{u'GROUP_EVERYONE': <cmislib.model.ACE object at 0x100731410>, u'jdoe': <cmislib.model.ACE object at 0x100731150>, 'jpotts': <cmislib.model.ACE object at 0x1005a22d0>}
class cmislib.model.ChangeEntry(cmisClient, repository, xmlDoc)

Represents a change log entry. Retrieve a list of change entries via Repository.getContentChanges().

>>> for changeEntry in rs:
...     changeEntry.objectId
...     changeEntry.id
...     changeEntry.changeType
...     changeEntry.changeTime
...
'workspace://SpacesStore/0e2dc775-16b7-4634-9e54-2417a196829b'
u'urn:uuid:0e2dc775-16b7-4634-9e54-2417a196829b'
u'created'
datetime.datetime(2010, 2, 11, 12, 55, 14)
'workspace://SpacesStore/bd768f9f-99a7-4033-828d-5b13f96c6923'
u'urn:uuid:bd768f9f-99a7-4033-828d-5b13f96c6923'
u'updated'
datetime.datetime(2010, 2, 11, 12, 55, 13)
'workspace://SpacesStore/572c2cac-6b26-4cd8-91ad-b2931fe5b3fb'
u'urn:uuid:572c2cac-6b26-4cd8-91ad-b2931fe5b3fb'
u'updated'
changeTime
Returns a datetime object representing the time the change occurred.
changeType

Returns the type of change that occurred. The resulting value must be one of:

  • created
  • updated
  • deleted
  • security
getACL()
Gets the ACL object that is included with this Change Entry.
getChangeTime()
Returns a datetime object representing the time the change occurred.
getChangeType()

Returns the type of change that occurred. The resulting value must be one of:

  • created
  • updated
  • deleted
  • security
getId()
Returns the unique ID of the change entry.
getObjectId()
Returns the object ID of the object that changed.
getProperties()
Returns the properties of the change entry. Note that depending on the capabilities of the repository (“capabilityChanges”) the list may not include the actual property values that changed.
id
Returns the unique ID of the change entry.
objectId
Returns the object ID of the object that changed.
properties
Returns the properties of the change entry. Note that depending on the capabilities of the repository (“capabilityChanges”) the list may not include the actual property values that changed.
class cmislib.model.ChangeEntryResultSet(cmisClient, repository, xmlDoc)

A specialized type of ResultSet that knows how to instantiate ChangeEntry objects. The parent class assumes children of CmisObject which doesn’t work for ChangeEntries.

getResults()
Overriding to make it work with a list instead of a dict.
class cmislib.model.CmisClient(repositoryUrl, username, password)

Handles all communication with the CMIS provider.

defaultRepository

There does not appear to be anything in the spec that identifies a repository as being the default, so we’ll define it to be the first one in the list.

>>> repo = client.getDefaultRepository()
>>> repo.getRepositoryId()
u'83beb297-a6fa-4ac5-844b-98c871c0eea9'
delete(url, **kwargs)

Does a delete against the CMIS service. More than likely, you will not need to call this method. Instead, let the other objects to it for you.

For example, to delete a folder you’d call Folder.delete and to delete a document you’d call Document.delete.

get(url, **kwargs)

Does a get against the CMIS service. More than likely, you will not need to call this method. Instead, let the other objects to it for you.

For example, if you need to get a specific object by object id, try Repository.getObject. If you have a path instead of an object id, use Repository.getObjectByPath. Or, you could start with the root folder (Repository.getRootFolder) and drill down from there.

getDefaultRepository()

There does not appear to be anything in the spec that identifies a repository as being the default, so we’ll define it to be the first one in the list.

>>> repo = client.getDefaultRepository()
>>> repo.getRepositoryId()
u'83beb297-a6fa-4ac5-844b-98c871c0eea9'
getRepositories()

Returns a dict of high-level info about the repositories available at this service. The dict contains entries for ‘repositoryId’ and ‘repositoryName’.

See CMIS specification document 2.2.2.1 getRepositories

>>> client.getRepositories()
[{'repositoryName': u'Main Repository', 'repositoryId': u'83beb297-a6fa-4ac5-844b-98c871c0eea9'}]
getRepository(repositoryId)

Returns the repository identified by the specified repositoryId.

>>> repo = client.getRepository('83beb297-a6fa-4ac5-844b-98c871c0eea9')
>>> repo.getRepositoryName()
u'Main Repository'
post(url, payload, contentType, **kwargs)

Does a post against the CMIS service. More than likely, you will not need to call this method. Instead, let the other objects to it for you.

For example, to update the properties on an object, you’d call CmisObject.updateProperties. Or, to check in a document that’s been checked out, you’d call Document.checkin on the PWC.

put(url, payload, contentType, **kwargs)

Does a put against the CMIS service. More than likely, you will not need to call this method. Instead, let the other objects to it for you.

For example, to update the properties on an object, you’d call CmisObject.updateProperties. Or, to check in a document that’s been checked out, you’d call Document.checkin on the PWC.

repositories

Returns a dict of high-level info about the repositories available at this service. The dict contains entries for ‘repositoryId’ and ‘repositoryName’.

See CMIS specification document 2.2.2.1 getRepositories

>>> client.getRepositories()
[{'repositoryName': u'Main Repository', 'repositoryId': u'83beb297-a6fa-4ac5-844b-98c871c0eea9'}]
class cmislib.model.CmisId
This is a marker class to be used for Strings that are used as CMIS ID’s. Making the objects instances of this class makes it easier to create the Atom entry XML with the appropriate type, ie, cmis:propertyId, instead of cmis:propertyString.
class cmislib.model.CmisObject(cmisClient, repository, objectId=None, xmlDoc=None, **kwargs)

Common ancestor class for other CMIS domain objects such as Document and Folder.

ACL

Repository.getCapabilities[‘ACL’] must return manage or discover.

>>> acl = folder.getACL()
>>> acl.getEntries()
{u'GROUP_EVERYONE': <cmislib.model.ACE object at 0x10071a8d0>, 'jdoe': <cmislib.model.ACE object at 0x10071a590>}

See CMIS specification document 2.2.10.1 getACL

The optional onlyBasicPermissions argument is currently not supported.

allowableActions

Returns a dictionary of allowable actions, keyed off of the action name.

>>> actions = doc.getAllowableActions()
>>> for a in actions:
...     print "%s:%s" % (a,actions[a])
...
canDeleteContentStream:True
canSetContentStream:True
canCreateRelationship:True
canCheckIn:False
canApplyACL:False
canDeleteObject:True
canGetAllVersions:True
canGetObjectParents:True
canGetProperties:True

See CMIS specification document 2.2.4.6 getAllowableActions

applyACL(acl)

Updates the object with the provided ACL. Repository.getCapabilities[‘ACL’] must return manage to invoke this call.

>>> acl = folder.getACL()
>>> acl.addEntry(ACE('jdoe', 'cmis:write', 'true'))
>>> acl.getEntries()
{u'GROUP_EVERYONE': <cmislib.model.ACE object at 0x10071a8d0>, 'jdoe': <cmislib.model.ACE object at 0x10071a590>}

See CMIS specification document 2.2.10.2 applyACL

applyPolicy(policyId)

This is not yet implemented.

See CMIS specification document 2.2.9.1 applyPolicy

createRelationship(targetObj, relTypeId)

Creates a relationship between this object and a specified target object using the relationship type specified. Returns the new Relationship object.

>>> rel = tstDoc1.createRelationship(tstDoc2, 'R:cmiscustom:assoc')
>>> rel.getProperties()
{u'cmis:objectId': u'workspace://SpacesStore/271c48dd-6548-4771-a8f5-0de69b7cdc25', u'cmis:creationDate': None, u'cmis:objectTypeId': u'R:cmiscustom:assoc', u'cmis:lastModificationDate': None, u'cmis:targetId': u'workspace://SpacesStore/0ca1aa08-cb49-42e2-8881-53aa8496a1c1', u'cmis:lastModifiedBy': None, u'cmis:baseTypeId': u'cmis:relationship', u'cmis:sourceId': u'workspace://SpacesStore/271c48dd-6548-4771-a8f5-0de69b7cdc25', u'cmis:changeToken': None, u'cmis:createdBy': None}
delete(**kwargs)

Deletes this CmisObject from the repository. Note that in the case of a Folder object, some repositories will refuse to delete it if it contains children and some will delete it without complaint. If what you really want to do is delete the folder and all of its descendants, use deleteTree() instead.

See CMIS specification document 2.2.4.14 delete

>>> folder.delete()

The optional allVersions argument is supported.

getACL()

Repository.getCapabilities[‘ACL’] must return manage or discover.

>>> acl = folder.getACL()
>>> acl.getEntries()
{u'GROUP_EVERYONE': <cmislib.model.ACE object at 0x10071a8d0>, 'jdoe': <cmislib.model.ACE object at 0x10071a590>}

See CMIS specification document 2.2.10.1 getACL

The optional onlyBasicPermissions argument is currently not supported.

getAllowableActions()

Returns a dictionary of allowable actions, keyed off of the action name.

>>> actions = doc.getAllowableActions()
>>> for a in actions:
...     print "%s:%s" % (a,actions[a])
...
canDeleteContentStream:True
canSetContentStream:True
canCreateRelationship:True
canCheckIn:False
canApplyACL:False
canDeleteObject:True
canGetAllVersions:True
canGetObjectParents:True
canGetProperties:True

See CMIS specification document 2.2.4.6 getAllowableActions

getAppliedPolicies()

This is not yet implemented.

See CMIS specification document 2.2.9.3 getAppliedPolicies

getName()

Returns the value of cmis:name from the getProperties() dictionary. We don’t need a getter for every standard CMIS property, but name is a pretty common one so it seems to make sense.

>>> doc.getName()
u'system-overview.html'
getObjectId()

Returns the object ID for this object.

>>> doc = resultSet.getResults()[0]
>>> doc.getObjectId()
u'workspace://SpacesStore/dc26102b-e312-471b-b2af-91bfb0225339'
getObjectParents()

This has not yet been implemented.

See CMIS specification document 2.2.3.5 getObjectParents

The following optional arguments are not supported:
  • filter
  • includeRelationships
  • renditionFilter
  • includeAllowableActions
  • includeRelativePathSegment
getProperties()

Returns a dict of the object’s properties. If CMIS returns an empty element for a property, the property will be in the dict with a value of None.

See CMIS specification document 2.2.4.8 getProperties

>>> props = doc.getProperties()
>>> for p in props:
...     print "%s: %s" % (p, props[p])
...
cmis:contentStreamMimeType: text/html
cmis:creationDate: 2009-12-15T09:45:35.369-06:00
cmis:baseTypeId: cmis:document
cmis:isLatestMajorVersion: false
cmis:isImmutable: false
cmis:isMajorVersion: false
cmis:objectId: workspace://SpacesStore/dc26102b-e312-471b-b2af-91bfb0225339

The optional filter argument is not yet implemented.

getRelationships(**kwargs)

Returns a ResultSet of Relationship objects for each relationship where the source is this object.

See CMIS specification document 2.2.8.1 getObjectRelationships

>>> rels = tstDoc1.getRelationships()
>>> len(rels.getResults())
1
>>> rel = rels.getResults().values()[0]
>>> rel.getProperties()
{u'cmis:objectId': u'workspace://SpacesStore/271c48dd-6548-4771-a8f5-0de69b7cdc25', u'cmis:creationDate': None, u'cmis:objectTypeId': u'R:cmiscustom:assoc', u'cmis:lastModificationDate': None, u'cmis:targetId': u'workspace://SpacesStore/0ca1aa08-cb49-42e2-8881-53aa8496a1c1', u'cmis:lastModifiedBy': None, u'cmis:baseTypeId': u'cmis:relationship', u'cmis:sourceId': u'workspace://SpacesStore/271c48dd-6548-4771-a8f5-0de69b7cdc25', u'cmis:changeToken': None, u'cmis:createdBy': None}
The following optional arguments are supported:
  • includeSubRelationshipTypes
  • relationshipDirection
  • typeId
  • maxItems
  • skipCount
  • filter
  • includeAllowableActions
getTitle()
Returns the value of the object’s cmis:title property.
id

Returns the object ID for this object.

>>> doc = resultSet.getResults()[0]
>>> doc.getObjectId()
u'workspace://SpacesStore/dc26102b-e312-471b-b2af-91bfb0225339'
move(targetFolderId, sourceFolderId)

This is not yet implemented.

See CMIS specification document 2.2.4.13 move

name

Returns the value of cmis:name from the getProperties() dictionary. We don’t need a getter for every standard CMIS property, but name is a pretty common one so it seems to make sense.

>>> doc.getName()
u'system-overview.html'
properties

Returns a dict of the object’s properties. If CMIS returns an empty element for a property, the property will be in the dict with a value of None.

See CMIS specification document 2.2.4.8 getProperties

>>> props = doc.getProperties()
>>> for p in props:
...     print "%s: %s" % (p, props[p])
...
cmis:contentStreamMimeType: text/html
cmis:creationDate: 2009-12-15T09:45:35.369-06:00
cmis:baseTypeId: cmis:document
cmis:isLatestMajorVersion: false
cmis:isImmutable: false
cmis:isMajorVersion: false
cmis:objectId: workspace://SpacesStore/dc26102b-e312-471b-b2af-91bfb0225339

The optional filter argument is not yet implemented.

reload(**kwargs)

Fetches the latest representation of this object from the CMIS service. Some methods, like ^Document.checkout do this for you.

If you call reload with a properties filter, the filter will be in effect on subsequent calls until the filter argument is changed. To reset to the full list of properties, call reload with filter set to ‘*’.

removePolicy(policyId)

This is not yet implemented.

See CMIS specification document 2.2.9.2 removePolicy

title
Returns the value of the object’s cmis:title property.
updateProperties(properties)

Updates the properties of an object with the properties provided. Only provide the set of properties that need to be updated.

See CMIS specification document 2.2.4.12 updateProperties

>>> folder = repo.getObjectByPath('/someFolder2')
>>> folder.getName()
u'someFolder2'
>>> props = {'cmis:name': 'someFolderFoo'}
>>> folder.updateProperties(props)
<cmislib.model.Folder object at 0x103ab1210>
>>> folder.getName()
u'someFolderFoo'

The optional changeToken is not yet supported.

class cmislib.model.Document(cmisClient, repository, objectId=None, xmlDoc=None, **kwargs)

An object typically associated with file content.

cancelCheckout()

Cancels the checkout of this object by retrieving the Private Working Copy (PWC) and then deleting it. After the PWC is deleted, this object will be reloaded to update properties related to a checkout.

See CMIS specification document 2.2.7.2 cancelCheckOut

>>> doc.isCheckedOut()
True
>>> doc.cancelCheckout()
>>> doc.isCheckedOut()
False
checkedOut

Returns true if the document is checked out.

>>> doc.isCheckedOut()
True
>>> doc.cancelCheckout()
>>> doc.isCheckedOut()
False
checkin(checkinComment=None, **kwargs)

Checks in this Document which must be a private working copy (PWC).

See CMIS specification document 2.2.7.3 checkIn

>>> doc.isCheckedOut()
False
>>> pwc = doc.checkout()
>>> doc.isCheckedOut()
True
>>> pwc.checkin()
<cmislib.model.Document object at 0x103a8ae90>
>>> doc.isCheckedOut()
False
The following optional arguments are supported:
  • major
  • properties
  • contentStream
  • policies
  • addACEs
  • removeACEs
checkout()

Performs a checkout on the Document and returns the Private Working Copy (PWC), which is also an instance of Document

See CMIS specification document 2.2.7.1 checkout

>>> doc.getObjectId()
u'workspace://SpacesStore/f0c8b90f-bec0-4405-8b9c-2ab570589808;1.0'
>>> doc.isCheckedOut()
False
>>> pwc = doc.checkout()
>>> doc.isCheckedOut()
True
deleteContentStream(changeToken=None)
See CMIS specification document 2.2.4.17 deleteContentStream
getAllVersions(**kwargs)

Returns a ResultSet of document objects for the entire version history of this object, including any PWC’s.

See CMIS specification document 2.2.7.5 getAllVersions

The optional filter and includeAllowableActions are supported.

getCheckedOutBy()
Returns the ID who currently has the document checked out. >>> pwc = doc.checkout() >>> pwc.getCheckedOutBy() u’admin’
getContentStream()

Returns the CMIS service response from invoking the ‘enclosure’ link.

See CMIS specification document 2.2.4.10 getContentStream

>>> doc.getName()
u'sample-b.pdf'
>>> o = open('tmp.pdf', 'wb')
>>> result = doc.getContentStream()
>>> o.write(result.read())
>>> result.close()
>>> o.close()
>>> import os.path
>>> os.path.getsize('tmp.pdf')
117248

The optional streamId argument is not yet supported.

getLatestVersion(**kwargs)

Returns a Document object representing the latest version in the version series. This is retrieved by See CMIS specification document 2.2.7.4 getObjectOfLatestVersion

The following optional arguments are supported:
  • major
  • filter
  • includeRelationships
  • includePolicyIds
  • renditionFilter
  • includeACL
  • includeAllowableActions
>>> latestDoc = doc.getLatestVersion()
>>> latestDoc.getProperties()['cmis:versionLabel']
u'2.1'
>>> latestDoc = doc.getLatestVersion(major='false')
>>> latestDoc.getProperties()['cmis:versionLabel']
u'2.1'
>>> latestDoc = doc.getLatestVersion(major='true')
>>> latestDoc.getProperties()['cmis:versionLabel']
u'2.0'
getPrivateWorkingCopy()

Retrieves the object using the object ID in the property: cmis:versionSeriesCheckedOutId then uses getObject to instantiate the object.

>>> doc.isCheckedOut()
False
>>> doc.checkout()
<cmislib.model.Document object at 0x103a25ad0>
>>> pwc = doc.getPrivateWorkingCopy()
>>> pwc.getTitle()
u'sample-b (Working Copy).pdf'
getPropertiesOfLatestVersion(**kwargs)

Like ^CmisObject.getProperties, returns a dict of properties from the latest version of this object in the version series.

See CMIS specification document 2.2.7.4 getPropertiesOfLatestVersion

The optional major and filter arguments are supported.

getRenditions()

This is not yet supported.

See CMIS specification document 2.2.4.11 getRenditions

The following optional arguments are not currently supported:
  • renditionFilter
  • maxItems
  • skipCount
isCheckedOut()

Returns true if the document is checked out.

>>> doc.isCheckedOut()
True
>>> doc.cancelCheckout()
>>> doc.isCheckedOut()
False
setContentStream(contentFile)

See CMIS specification document 2.2.4.16 setContentStream

The following optional arguments are not yet supported:
  • overwriteFlag=None,
  • changeToken=None
class cmislib.model.Folder(cmisClient, repository, objectId=None, xmlDoc=None, **kwargs)

A container object that can hold other CmisObject objects

addObject(cmisObject)

This is not yet implemented.

See CMIS specification document 2.2.5.1 addObjectToFolder

The optional allVersions argument is not yet supported.

createDocument(name, properties={}, contentFile=None, contentType=None, contentEncoding=None)

Creates a new Document object in the repository using the properties provided.

Right now this is basically the same as createFolder, but this deals with contentStreams. The common logic should probably be moved to CmisObject.createObject.

The method will attempt to guess the appropriate content type and encoding based on the file. To specify it yourself, pass them in via the contentType and contentEncoding arguments.

>>> f = open('250px-Cmis_logo.png', 'rb')
>>> subFolder.createDocument('logo.png', contentFile=f)
<cmislib.model.Document object at 0x10410fa10>
>>> f.close()

If you wanted to set one or more properties when creating the doc, pass in a dict, like this:

>>> props = {'cmis:someProp':'someVal'}
>>> f = open('250px-Cmis_logo.png', 'rb')
>>> subFolder.createDocument('logo.png', props, contentFile=f)
<cmislib.model.Document object at 0x10410fa10>
>>> f.close()

To specify a custom object type, pass in a property called cmis:objectTypeId set to the CmisId representing the type ID of the instance you want to create. If you do not pass in an object type ID, an instance of ‘cmis:document’ will be created.

The following optional arguments are not yet supported:
  • versioningState
  • policies
  • addACEs
  • removeACEs
createFolder(name, properties={})

Creates a new Folder using the properties provided. Right now I expect a property called ‘cmis:name’ but I don’t complain if it isn’t there (although the CMIS provider will). If a cmis:name property isn’t provided, the value passed in to the name argument will be used.

To specify a custom folder type, pass in a property called cmis:objectTypeId set to the CmisId representing the type ID of the instance you want to create. If you do not pass in an object type ID, an instance of ‘cmis:folder’ will be created.

>>> subFolder = folder.createFolder('someSubfolder')
>>> subFolder.getName()
u'someSubfolder'
The following optional arguments are not supported:
  • policies
  • addACEs
  • removeACEs
deleteTree(**kwargs)

Deletes the folder and all of its descendant objects.

See CMIS specification document 2.2.4.15 deleteTree

>>> resultSet = subFolder.getDescendants()
>>> len(resultSet.getResults())
2
>>> subFolder.deleteTree()
The following optional arguments are supported:
  • allVersions
  • unfileObjects
  • continueOnFailure
getChildren(**kwargs)

Returns a paged ResultSet. The result set contains a list of CmisObject objects for each child of the Folder. The actual type of the object returned depends on the object’s CMIS base type id. For example, the method might return a list that contains both Document objects and Folder objects.

See CMIS specification document 2.2.3.1 getChildren

>>> childrenRS = subFolder.getChildren()
>>> children = childrenRS.getResults()
The following optional arguments are supported:
  • maxItems
  • skipCount
  • orderBy
  • filter
  • includeRelationships
  • renditionFilter
  • includeAllowableActions
  • includePathSegment
Gets the Atom link that knows how to return this object’s children.
getDescendants(**kwargs)

Gets the descendants of this folder. The descendants are returned as a paged ResultSet object. The result set contains a list of CmisObject objects where the actual type of each object returned will vary depending on the object’s base type id. For example, the method might return a list that contains both Document objects and Folder objects.

See CMIS specification document 2.2.3.2 getDescendants

The following optional argument is supported:
  • depth. Use depth=-1 for all descendants, which is the default if no depth is specified.
>>> resultSet = folder.getDescendants()
>>> len(resultSet.getResults())
105
>>> resultSet = folder.getDescendants(depth=1)
>>> len(resultSet.getResults())
103

The following optional arguments may also work but haven’t been tested:

  • filter
  • includeRelationships
  • renditionFilter
  • includeAllowableActions
  • includePathSegment

Returns the ‘down’ link of type CMIS_TREE_TYPE

>>> folder.getDescendantsLink()
u'http://localhost:8080/alfresco/s/cmis/s/workspace:SpacesStore/i/86f6bf54-f0e8-4a72-8cb1-213599ba086c/descendants'
getParent()

This is not yet implemented.

See CMIS specification document 2.2.3.4 getFolderParent

The optional filter argument is not yet supported.

getTree(**kwargs)

Unlike Folder.getChildren or Folder.getDescendants, this method returns only the descendant objects that are folders. The results do not include the current folder.

See CMIS specification document 2.2.3.3 getFolderTree

The following optional arguments are supported:
  • depth
  • filter
  • includeRelationships
  • renditionFilter
  • includeAllowableActions
  • includePathSegment
>>> rs = folder.getTree(depth='2')
>>> len(rs.getResults())
3
>>> for folder in rs.getResults().values():
...     folder.getTitle()
...
u'subfolder2'
u'parent test folder'
u'subfolder'
removeObject(cmisObject)

This is not yet implemented.

See CMIS specification document 2.2.5.2 removeObjectFromFolder

class cmislib.model.ObjectType(cmisClient, repository, typeId=None, xmlDoc=None)

Represents the CMIS object type such as ‘cmis:document’ or ‘cmis:folder’. Contains metadata about the type.

baseId
Getter for cmis:baseId
controllableACL
Getter for cmis:controllableACL
controllablePolicy
Getter for cmis:controllablePolicy
creatable
Getter for cmis:creatable
description
Getter for cmis:description
displayName
Getter for cmis:displayName
fileable
Getter for cmis:fileable
fulltextIndexed
Getter for cmis:fulltextIndexed
getBaseId()
Getter for cmis:baseId
getDescription()
Getter for cmis:description
getDisplayName()
Getter for cmis:displayName

Gets the HREF for the link element with the specified rel and linkType.

>>> from cmislib.model import ATOM_XML_FEED_TYPE
>>> docType.getLink('down', ATOM_XML_FEED_TYPE)
u'http://localhost:8080/alfresco/s/cmis/type/cmis:document/children'
getLocalName()
Getter for cmis:localName
getLocalNamespace()
Getter for cmis:localNamespace
getProperties()

Returns a list of Property objects representing each property defined for this type.

>>> objType = repo.getTypeDefinition('cmis:relationship')
>>> for prop in objType.properties:
...    print 'Id:%s' % prop.id
...    print 'Cardinality:%s' % prop.cardinality
...    print 'Description:%s' % prop.description
...    print 'Display name:%s' % prop.displayName
...    print 'Local name:%s' % prop.localName
...    print 'Local namespace:%s' % prop.localNamespace
...    print 'Property type:%s' % prop.propertyType
...    print 'Query name:%s' % prop.queryName
...    print 'Updatability:%s' % prop.updatability
...    print 'Inherited:%s' % prop.inherited
...    print 'Orderable:%s' % prop.orderable
...    print 'Queryable:%s' % prop.queryable
...    print 'Required:%s' % prop.required
...    print 'Open choice:%s' % prop.openChoice
getQueryName()
Getter for cmis:queryName
getTypeId()

Returns the type ID for this object.

>>> docType = repo.getTypeDefinition('cmis:document')
>>> docType.getTypeId()
'cmis:document'
id

Returns the type ID for this object.

>>> docType = repo.getTypeDefinition('cmis:document')
>>> docType.getTypeId()
'cmis:document'
includedInSupertypeQuery
Getter for cmis:includedInSupertypeQuery
isControllableACL()
Getter for cmis:controllableACL
isControllablePolicy()
Getter for cmis:controllablePolicy
isCreatable()
Getter for cmis:creatable
isFileable()
Getter for cmis:fileable
isFulltextIndexed()
Getter for cmis:fulltextIndexed
isIncludedInSupertypeQuery()
Getter for cmis:includedInSupertypeQuery
isQueryable()
Getter for cmis:queryable
localName
Getter for cmis:localName
localNamespace
Getter for cmis:localNamespace
properties

Returns a list of Property objects representing each property defined for this type.

>>> objType = repo.getTypeDefinition('cmis:relationship')
>>> for prop in objType.properties:
...    print 'Id:%s' % prop.id
...    print 'Cardinality:%s' % prop.cardinality
...    print 'Description:%s' % prop.description
...    print 'Display name:%s' % prop.displayName
...    print 'Local name:%s' % prop.localName
...    print 'Local namespace:%s' % prop.localNamespace
...    print 'Property type:%s' % prop.propertyType
...    print 'Query name:%s' % prop.queryName
...    print 'Updatability:%s' % prop.updatability
...    print 'Inherited:%s' % prop.inherited
...    print 'Orderable:%s' % prop.orderable
...    print 'Queryable:%s' % prop.queryable
...    print 'Required:%s' % prop.required
...    print 'Open choice:%s' % prop.openChoice
queryName
Getter for cmis:queryName
queryable
Getter for cmis:queryable
reload(**kwargs)
This method will reload the object’s data from the CMIS service.
class cmislib.model.Policy(cmisClient, repository, objectId=None, xmlDoc=None, **kwargs)
An arbirary object that can ‘applied’ to objects that the repository identifies as being ‘controllable’.
class cmislib.model.Property(propNode)

This class represents an attribute or property definition of an object type.

cardinality
Getter for cmis:cardinality
description
Getter for cmis:description
displayName
Getter for cmis:displayName
getCardinality()
Getter for cmis:cardinality
getDescription()
Getter for cmis:description
getDisplayName()
Getter for cmis:displayName
getId()
Getter for cmis:id
getLocalName()
Getter for cmis:localName
getLocalNamespace()
Getter for cmis:localNamespace
getPropertyType()
Getter for cmis:propertyType
getQueryName()
Getter for cmis:queryName
getUpdatability()
Getter for cmis:updatability
id
Getter for cmis:id
inherited
Getter for cmis:inherited
isInherited()
Getter for cmis:inherited
isOpenChoice()
Getter for cmis:openChoice
isOrderable()
Getter for cmis:orderable
isQueryable()
Getter for cmis:queryable
isRequired()
Getter for cmis:required
localName
Getter for cmis:localName
localNamespace
Getter for cmis:localNamespace
openChoice
Getter for cmis:openChoice
orderable
Getter for cmis:orderable
propertyType
Getter for cmis:propertyType
queryName
Getter for cmis:queryName
queryable
Getter for cmis:queryable
required
Getter for cmis:required
updatability
Getter for cmis:updatability
class cmislib.model.Relationship(cmisClient, repository, objectId=None, xmlDoc=None, **kwargs)

Defines a relationship object between two CmisObjects objects

getSource()
Returns an instance of the appropriate child-type of CmisObject for the source side of the relationship.
getSourceId()
Returns the CmisId on the source side of the relationship.
getTarget()
Returns an instance of the appropriate child-type of CmisObject for the target side of the relationship.
getTargetId()
Returns the CmisId on the target side of the relationship.
source
Returns an instance of the appropriate child-type of CmisObject for the source side of the relationship.
sourceId
Returns the CmisId on the source side of the relationship.
target
Returns an instance of the appropriate child-type of CmisObject for the target side of the relationship.
targetId
Returns the CmisId on the target side of the relationship.
class cmislib.model.Repository(cmisClient, xmlDoc=None)

Represents a CMIS repository. Will lazily populate itself by calling the repository CMIS service URL.

You must pass in an instance of a CmisClient when creating an instance of this class.

See CMIS specification document 2.1.1 Repository

capabilities

Returns a dict of repository capabilities.

>>> caps = repo.getCapabilities()
>>> for k,v in caps.items():
...     print "%s:%s" % (k,v)
...
PWCUpdatable:True
VersionSpecificFiling:False
Join:None
ContentStreamUpdatability:anytime
AllVersionsSearchable:False
Renditions:None
Multifiling:True
GetFolderTree:True
GetDescendants:True
ACL:None
PWCSearchable:True
Query:bothcombined
Unfiling:False
Changes:None
createDocument(name, properties={}, parentFolder=None, contentFile=None, contentType=None, contentEncoding=None)

Creates a new Document object. If the repository supports unfiled objects, you do not have to pass in a parent Folder otherwise it is required.

To create a document with an associated contentFile, pass in a File object. The method will attempt to guess the appropriate content type and encoding based on the file. To specify it yourself, pass them in via the contentType and contentEncoding arguments.

See CMIS specification document 2.2.4.1 createDocument

>>> f = open('sample-a.pdf', 'rb')
>>> doc = folder.createDocument('sample-a.pdf', contentFile=f)
<cmislib.model.Document object at 0x105be5e10>
>>> f.close()
>>> doc.getTitle()
u'sample-a.pdf'
The following optional arguments are not currently supported:
  • versioningState
  • policies
  • addACEs
  • removeACEs
createDocumentFromSource(sourceId, properties={}, parentFolder=None)

This is not yet implemented.

See CMIS specification document 2.2.4.2 createDocumentFromSource

The following optional arguments are not yet supported:
  • versioningState
  • policies
  • addACEs
  • removeACEs
createFolder(parentFolder, name, properties={})

Creates a new Folder object in the specified parentFolder.

See CMIS specification document 2.2.4.3 createFolder

>>> root = repo.getRootFolder()
>>> folder = repo.createFolder(root, 'someFolder2')
>>> folder.getTitle()
u'someFolder2'
>>> folder.getObjectId()
u'workspace://SpacesStore/2224a63c-350b-438c-be72-8f425e79ce1f'
The following optional arguments are not yet supported:
  • policies
  • addACEs
  • removeACEs
createPolicy(properties)

This has not yet been implemented.

See CMIS specification document 2.2.4.5 createPolicy

The following optional arguments are not currently supported:
  • folderId
  • policies
  • addACEs
  • removeACEs
createRelationship(sourceObj, targetObj, relType)

Creates a relationship of the specific type between a source object and a target object and returns the new Relationship object.

See CMIS specification document 2.2.4.4 createRelationship

The following optional arguments are not currently supported:
  • policies
  • addACEs
  • removeACEs
getCapabilities()

Returns a dict of repository capabilities.

>>> caps = repo.getCapabilities()
>>> for k,v in caps.items():
...     print "%s:%s" % (k,v)
...
PWCUpdatable:True
VersionSpecificFiling:False
Join:None
ContentStreamUpdatability:anytime
AllVersionsSearchable:False
Renditions:None
Multifiling:True
GetFolderTree:True
GetDescendants:True
ACL:None
PWCSearchable:True
Query:bothcombined
Unfiling:False
Changes:None
getCheckedOutDocs(**kwargs)

Returns a ResultSet of CmisObject objects that are currently checked out.

See CMIS specification document 2.2.3.6 getCheckedOutDocs

>>> rs = repo.getCheckedOutDocs()
>>> len(rs.getResults())
2
>>> for doc in repo.getCheckedOutDocs().getResults():
...     doc.getTitle()
...
u'sample-a (Working Copy).pdf'
u'sample-b (Working Copy).pdf'
These optional arguments are supported:
  • folderId
  • maxItems
  • skipCount
  • orderBy
  • filter
  • includeRelationships
  • renditionFilter
  • includeAllowableActions
getCollection(collectionType, **kwargs)

Returns a list of objects returned for the specified collection.

If the query collection is requested, an exception will be raised. That collection isn’t meant to be retrieved.

If the types collection is specified, the method returns the result of getTypeDefinitions and ignores any optional params passed in.

>>> from cmislib.model import TYPES_COLL
>>> types = repo.getCollection(TYPES_COLL)
>>> len(types)
4
>>> types[0].getTypeId()
u'cmis:folder'

Otherwise, the collection URL is invoked, and a ResultSet is returned.

>>> from cmislib.model import CHECKED_OUT_COLL
>>> resultSet = repo.getCollection(CHECKED_OUT_COLL)
>>> len(resultSet.getResults())
1

Returns the link HREF from the specified collectionType (‘checkedout’, for example).

>>> from cmislib.model import CHECKED_OUT_COLL
>>> repo.getCollectionLink(CHECKED_OUT_COLL)
u'http://localhost:8080/alfresco/s/cmis/checkedout'
getContentChanges(**kwargs)

Returns a ResultSet containing ChangeEntry objects.

>>> for changeEntry in rs:
...     changeEntry.objectId
...     changeEntry.id
...     changeEntry.changeType
...     changeEntry.changeTime
...
'workspace://SpacesStore/0e2dc775-16b7-4634-9e54-2417a196829b'
u'urn:uuid:0e2dc775-16b7-4634-9e54-2417a196829b'
u'created'
datetime.datetime(2010, 2, 11, 12, 55, 14)
'workspace://SpacesStore/bd768f9f-99a7-4033-828d-5b13f96c6923'
u'urn:uuid:bd768f9f-99a7-4033-828d-5b13f96c6923'
u'updated'
datetime.datetime(2010, 2, 11, 12, 55, 13)
'workspace://SpacesStore/572c2cac-6b26-4cd8-91ad-b2931fe5b3fb'
u'urn:uuid:572c2cac-6b26-4cd8-91ad-b2931fe5b3fb'
u'updated'

See CMIS specification document 2.2.6.2 getContentChanges

The following optional arguments are supported:
  • changeLogToken
  • includeProperties
  • includePolicyIDs
  • includeACL
  • maxItems

You can get the latest change log token by inspecting the repository info via Repository.getRepositoryInfo().

>>> repo.info['latestChangeLogToken']
u'2692'
>>> rs = repo.getContentChanges(changeLogToken='2692')
>>> len(rs)
1
>>> rs[0].id
u'urn:uuid:8e88f694-93ef-44c5-9f70-f12fff824be9'
>>> rs[0].changeType
u'updated'
>>> rs[0].changeTime
datetime.datetime(2010, 2, 16, 20, 6, 37)
getFolder(folderId)

Returns a Folder object for a specified folderId

>>> someFolder = repo.getFolder('workspace://SpacesStore/aa1ecedf-9551-49c5-831a-0502bb43f348')
>>> someFolder.getObjectId()
u'workspace://SpacesStore/aa1ecedf-9551-49c5-831a-0502bb43f348'
Returns the HREF attribute of an Atom link element for the specified rel.
getObject(objectId, **kwargs)

Returns an object given the specified object ID.

See CMIS specification document 2.2.4.7 getObject

>>> doc = repo.getObject('workspace://SpacesStore/f0c8b90f-bec0-4405-8b9c-2ab570589808')
>>> doc.getTitle()
u'sample-b.pdf'
The following optional arguments are supported:
  • returnVersion
  • filter
  • includeRelationships
  • includePolicyIds
  • renditionFilter
  • includeACL
  • includeAllowableActions
getObjectByPath(path, **kwargs)

Returns an object given the path to the object.

See CMIS specification document 2.2.4.9 getObjectByPath

>>> doc = repo.getObjectByPath('/jeff test/sample-b.pdf')
>>> doc.getTitle()
u'sample-b.pdf'
The following optional arguments are not currently supported:
  • filter
  • includeAllowableActions
getPermissionDefinitions()

Returns a dictionary of permission definitions for this repository. The key is the permission string or technical name of the permission and the value is the permission description.

>>> for permDef in repo.permissionDefinitions:
...     print permDef
...
cmis:all
{http://www.alfresco.org/model/system/1.0}base.LinkChildren
{http://www.alfresco.org/model/content/1.0}folder.Consumer
{http://www.alfresco.org/model/security/1.0}All.All
{http://www.alfresco.org/model/system/1.0}base.CreateAssociations
{http://www.alfresco.org/model/system/1.0}base.FullControl
{http://www.alfresco.org/model/system/1.0}base.AddChildren
{http://www.alfresco.org/model/system/1.0}base.ReadAssociations
{http://www.alfresco.org/model/content/1.0}folder.Editor
{http://www.alfresco.org/model/content/1.0}cmobject.Editor
{http://www.alfresco.org/model/system/1.0}base.DeleteAssociations
cmis:read
cmis:write
getPermissionMap()

Returns a dictionary representing the permission mapping table where each key is a permission key string and each value is a list of one or more permissions the principal must have to perform the operation.

>>> for (k,v) in repo.permissionMap.items():
...     print 'To do this: %s, you must have these perms:' % k
...     for perm in v:
...             print perm
...
To do this: canCreateFolder.Folder, you must have these perms:
cmis:all
{http://www.alfresco.org/model/system/1.0}base.CreateChildren
To do this: canAddToFolder.Folder, you must have these perms:
cmis:all
{http://www.alfresco.org/model/system/1.0}base.CreateChildren
To do this: canDelete.Object, you must have these perms:
cmis:all
{http://www.alfresco.org/model/system/1.0}base.DeleteNode
To do this: canCheckin.Document, you must have these perms:
cmis:all
{http://www.alfresco.org/model/content/1.0}lockable.CheckIn
getPropagation()
Returns the value of the cmis:propagation element. Valid values are:
objectonly: indicates that the repository is able to apply ACEs
without changing the ACLs of other objects
propagate: indicates that the repository is able to apply ACEs to a
given object and propagate this change to all inheriting objects
>>> repo.propagation
u'propagate'
getRepositoryId()

Returns this repository’s unique identifier

>>> repo = client.getDefaultRepository()
>>> repo.getRepositoryId()
u'83beb297-a6fa-4ac5-844b-98c871c0eea9'
getRepositoryInfo()

Returns a dict of repository information.

See CMIS specification document 2.2.2.2 getRepositoryInfo

>>> repo = client.getDefaultRepository()>>> repo.getRepositoryName()
u'Main Repository'
>>> info = repo.getRepositoryInfo()
>>> for k,v in info.items():
...     print "%s:%s" % (k,v)
...
cmisSpecificationTitle:Version 1.0 Committee Draft 04
cmisVersionSupported:1.0
repositoryDescription:None
productVersion:3.2.0 (r2 2440)
rootFolderId:workspace://SpacesStore/aa1ecedf-9551-49c5-831a-0502bb43f348
repositoryId:83beb297-a6fa-4ac5-844b-98c871c0eea9
repositoryName:Main Repository
vendorName:Alfresco
productName:Alfresco Repository (Community)
getRepositoryName()

Returns this repository’s name

>>> repo = client.getDefaultRepository()
>>> repo.getRepositoryName()
u'Main Repository'
getRootFolder()

Returns the root folder of the repository

>>> root = repo.getRootFolder()
>>> root.getObjectId()
u'workspace://SpacesStore/aa1ecedf-9551-49c5-831a-0502bb43f348'
getSupportedPermissions()

Returns the value of the cmis:supportedPermissions element. Valid values are:

basic: indicates that the CMIS Basic permissions are supported repository: indicates that repository specific permissions are supported both: indicates that both CMIS basic permissions and repository specific permissions are supported
>>> repo.supportedPermissions
u'both'
getTypeChildren(typeId=None)

Returns a list of ObjectType objects corresponding to the child types of the type specified by the typeId.

If no typeId is provided, the result will be the same as calling self.getTypeDefinitions

See CMIS specification document 2.2.2.3 getTypeChildren

These optional arguments are current unsupported:
  • includePropertyDefinitions
  • maxItems
  • skipCount
>>> baseTypes = repo.getTypeChildren()
>>> for baseType in baseTypes:
...     print baseType.getTypeId()
...
cmis:folder
cmis:relationship
cmis:document
cmis:policy
getTypeDefinition(typeId)

Returns an ObjectType object for the specified object type id.

See CMIS specification document 2.2.2.5 getTypeDefinition

>>> folderType = repo.getTypeDefinition('cmis:folder')
getTypeDefinitions(**kwargs)

Returns a list of ObjectType objects representing the base types in the repository.

>>> baseTypes = repo.getTypeDefinitions()
>>> for baseType in baseTypes:
...     print baseType.getTypeId()
...
cmis:folder
cmis:relationship
cmis:document
cmis:policy
getTypeDescendants(typeId=None, **kwargs)

Returns a list of ObjectType objects corresponding to the descendant types of the type specified by the typeId.

If no typeId is provided, the repository’s “typesdescendants” URL will be called to determine the list of descendant types.

See CMIS specification document 2.2.2.4 getTypeDescendants

>>> allTypes = repo.getTypeDescendants()
>>> for aType in allTypes:
...     print aType.getTypeId()
...
cmis:folder
F:cm:systemfolder
F:act:savedactionfolder
F:app:configurations
F:fm:forums
F:wcm:avmfolder
F:wcm:avmplainfolder
F:wca:webfolder
F:wcm:avmlayeredfolder
F:st:site
F:app:glossary
F:fm:topic
These optional arguments are supported:
  • depth
  • includePropertyDefinitions
>>> types = alfRepo.getTypeDescendants('cmis:folder')
>>> len(types)
17
>>> types = alfRepo.getTypeDescendants('cmis:folder', depth=1)
>>> len(types)
12
>>> types = alfRepo.getTypeDescendants('cmis:folder', depth=2)
>>> len(types)
17
getUnfiledDocs(**kwargs)

Returns a ResultSet of CmisObject objects that are currently unfiled.

>>> rs = repo.getUnfiledDocs()
>>> len(rs.getResults())
2
>>> for doc in repo.getUnfiledDocs().getResults():
...     doc.getTitle()
...
u'sample-a.pdf'
u'sample-b.pdf'
These optional arguments are supported:
  • folderId
  • maxItems
  • skipCount
  • orderBy
  • filter
  • includeRelationships
  • renditionFilter
  • includeAllowableActions
getUriTemplates()

Returns a list of the URI templates the repository service knows about.

>>> templates = repo.getUriTemplates()
>>> templates['typebyid']['mediaType']
u'application/atom+xml;type=entry'
>>> templates['typebyid']['template']
u'http://localhost:8080/alfresco/s/cmis/type/{id}'
id

Returns this repository’s unique identifier

>>> repo = client.getDefaultRepository()
>>> repo.getRepositoryId()
u'83beb297-a6fa-4ac5-844b-98c871c0eea9'
info

Returns a dict of repository information.

See CMIS specification document 2.2.2.2 getRepositoryInfo

>>> repo = client.getDefaultRepository()>>> repo.getRepositoryName()
u'Main Repository'
>>> info = repo.getRepositoryInfo()
>>> for k,v in info.items():
...     print "%s:%s" % (k,v)
...
cmisSpecificationTitle:Version 1.0 Committee Draft 04
cmisVersionSupported:1.0
repositoryDescription:None
productVersion:3.2.0 (r2 2440)
rootFolderId:workspace://SpacesStore/aa1ecedf-9551-49c5-831a-0502bb43f348
repositoryId:83beb297-a6fa-4ac5-844b-98c871c0eea9
repositoryName:Main Repository
vendorName:Alfresco
productName:Alfresco Repository (Community)
name

Returns this repository’s name

>>> repo = client.getDefaultRepository()
>>> repo.getRepositoryName()
u'Main Repository'
permissionDefinitions

Returns a dictionary of permission definitions for this repository. The key is the permission string or technical name of the permission and the value is the permission description.

>>> for permDef in repo.permissionDefinitions:
...     print permDef
...
cmis:all
{http://www.alfresco.org/model/system/1.0}base.LinkChildren
{http://www.alfresco.org/model/content/1.0}folder.Consumer
{http://www.alfresco.org/model/security/1.0}All.All
{http://www.alfresco.org/model/system/1.0}base.CreateAssociations
{http://www.alfresco.org/model/system/1.0}base.FullControl
{http://www.alfresco.org/model/system/1.0}base.AddChildren
{http://www.alfresco.org/model/system/1.0}base.ReadAssociations
{http://www.alfresco.org/model/content/1.0}folder.Editor
{http://www.alfresco.org/model/content/1.0}cmobject.Editor
{http://www.alfresco.org/model/system/1.0}base.DeleteAssociations
cmis:read
cmis:write
permissionMap

Returns a dictionary representing the permission mapping table where each key is a permission key string and each value is a list of one or more permissions the principal must have to perform the operation.

>>> for (k,v) in repo.permissionMap.items():
...     print 'To do this: %s, you must have these perms:' % k
...     for perm in v:
...             print perm
...
To do this: canCreateFolder.Folder, you must have these perms:
cmis:all
{http://www.alfresco.org/model/system/1.0}base.CreateChildren
To do this: canAddToFolder.Folder, you must have these perms:
cmis:all
{http://www.alfresco.org/model/system/1.0}base.CreateChildren
To do this: canDelete.Object, you must have these perms:
cmis:all
{http://www.alfresco.org/model/system/1.0}base.DeleteNode
To do this: canCheckin.Document, you must have these perms:
cmis:all
{http://www.alfresco.org/model/content/1.0}lockable.CheckIn
propagation
Returns the value of the cmis:propagation element. Valid values are:
objectonly: indicates that the repository is able to apply ACEs
without changing the ACLs of other objects
propagate: indicates that the repository is able to apply ACEs to a
given object and propagate this change to all inheriting objects
>>> repo.propagation
u'propagate'
query(statement, **kwargs)

Returns a list of CmisObject objects based on the CMIS Query Language passed in as the statement. The actual objects returned will be instances of the appropriate child class based on the object’s base type ID.

In order for the results to be properly instantiated as objects, make sure you include ‘cmis:objectId’ as one of the fields in your select statement, or just use “SELECT *”.

If you want the search results to automatically be instantiated with the appropriate sub-class of CmisObject you must either include cmis:baseTypeId as one of the fields in your select statement or just use “SELECT *”.

See CMIS specification document 2.2.6.1 query

>>> q = "select * from cmis:document where cmis:name like '%test%'"
>>> resultSet = repo.query(q)
>>> len(resultSet.getResults())
1
>>> resultSet.hasNext()
False
The following optional arguments are supported:
  • searchAllVersions
  • includeRelationships
  • renditionFilter
  • includeAllowableActions
  • maxItems
  • skipCount
>>> q = 'select * from cmis:document'
>>> rs = repo.query(q)
>>> len(rs.getResults())
148
>>> rs = repo.query(q, maxItems='5')
>>> len(rs.getResults())
5
>>> rs.hasNext()
True
reload()
This method will re-fetch the repository’s XML data from the CMIS repository.
rootFolder

Returns the root folder of the repository

>>> root = repo.getRootFolder()
>>> root.getObjectId()
u'workspace://SpacesStore/aa1ecedf-9551-49c5-831a-0502bb43f348'
supportedPermissions

Returns the value of the cmis:supportedPermissions element. Valid values are:

basic: indicates that the CMIS Basic permissions are supported repository: indicates that repository specific permissions are supported both: indicates that both CMIS basic permissions and repository specific permissions are supported
>>> repo.supportedPermissions
u'both'
class cmislib.model.ResultSet(cmisClient, repository, xmlDoc)

Represents a paged result set. In CMIS, this is most often an Atom feed.

getFirst()

Returns the first page of results as a dictionary of CmisObject objects or its appropriate sub-type. This only works when the server returns a “first” link. Not all of them do.

>>> resultSet.hasFirst()
True
>>> results = resultSet.getFirst()
>>> for result in results:
...     result
...
<cmislib.model.Document object at 0x10480bc90>
getLast()

Returns the last page of results as a dictionary of CmisObject objects or its appropriate sub-type. This only works when the server is returning a “last” link. Not all of them do.

>>> resultSet.hasLast()
True
>>> results = resultSet.getLast()
>>> for result in results:
...     result
...
<cmislib.model.Document object at 0x10480bc90>
getNext()
Returns the next page of results as a dictionary of CmisObject objects or its appropriate sub-type. >>> resultSet.hasNext() True >>> results = resultSet.getNext() >>> for result in results: ... result ... <cmislib.model.Document object at 0x10480bc90>
getPrev()
Returns the prev page of results as a dictionary of CmisObject objects or its appropriate sub-type. This only works when the server returns a “prev” link. Not all of them do. >>> resultSet.hasPrev() True >>> results = resultSet.getPrev() >>> for result in results: ... result ... <cmislib.model.Document object at 0x10480bc90>
getResults()

Returns the results that were fetched and cached by the get*Page call.

>>> resultSet = repo.getCheckedOutDocs()
>>> resultSet.hasNext()
False
>>> for result in resultSet.getResults():
...     result
...
<cmislib.model.Document object at 0x104851810>
hasFirst()

Returns True if this page contains a first link. Not all CMIS providers implement first links consistently.

>>> resultSet.hasFirst()
True
hasLast()

Returns True if this page contains a last link. Not all CMIS providers implement last links consistently.

>>> resultSet.hasLast()
True
hasNext()

Returns True if this page contains a next link.

>>> resultSet.hasNext()
True
hasPrev()

Returns True if this page contains a prev link. Not all CMIS providers implement prev links consistently.

>>> resultSet.hasPrev()
True
reload()

Re-invokes the self link for the current set of results.

>>> resultSet = repo.getCollection(CHECKED_OUT_COLL)
>>> resultSet.reload()
class cmislib.model.UriTemplate(template, templateType, mediaType)
Simple dictionary to represent the data stored in a URI template entry.
cmislib.model.getSpecializedObject(obj, **kwargs)
Returns an instance of the appropriate CmisObject class or one of its child types depending on the specified baseType.
cmislib.model.multiple_replace(aDict, text)

Replace in ‘text’ all occurences of any key in the given dictionary by its corresponding value. Returns the new string.

See http://code.activestate.com/recipes/81330/

cmislib.model.parseBoolValue(value)
Utility function to parse booleans and none from strings
cmislib.model.parseDateTimeValue(value)
Utility function to return a datetime from a string.
cmislib.model.parsePropValue(value, nodeName)
Returns a properly-typed object based on the type as specified in the node’s element name.
cmislib.model.toCMISValue(value)
Utility function to convert Python values to CMIS string values

The cmislib.net Module

The cmislib.net Module contains the classes used by cmislib.model.CmisClient to communicate with the CMIS repository. The most important of which is cmislib.net.RESTService.

Module that knows how to connect to the AtomPub Binding of a CMIS repo

class cmislib.net.RESTService

Generic service for interacting with an HTTP end point. Sets headers such as the USER_AGENT and builds the basic auth handler.

delete(url, username=None, password=None, **kwargs)
Makes a delete request to the URL specified.
get(url, username=None, password=None, **kwargs)
Makes a get request to the URL specified.
post(url, payload, contentType, username=None, password=None, **kwargs)
Makes a POST request to the URL specified and posts the payload that gets passed in. The content type header gets set to the specified content type.
put(url, payload, contentType, username=None, password=None, **kwargs)
Makes a PUT request to the URL specified and includes the payload that gets passed in. The content type header gets set to the specified content type.

The tests.cmislib Module

The tests.cmislibtest Module contains unit tests for all classes and methods in cmislib.model. See Tests for more information on running tests.

Unit tests for cmislib

class tests.cmislibtest.ACLTest(methodName='runTest')

Tests related to ACL and ACE

testApplyACL()
Test updating an object’s ACL
testGetObjectACL()
Test getting an object’s ACL
testPermissionDefinitions()
Test the list of permission definitions
testPermissionMap()
Test the permission mapping
testPropagation()
Test the propagation setting
testSupportedPermissions()
Test the value of supported permissions enum
class tests.cmislibtest.ChangeEntryTest(methodName='runTest')

Tests for the ChangeEntry class

testGetACL()
Gets the ACL that is included with a Change Entry.
testGetContentChanges()
Get the content changes and inspect Change Entry props
testGetProperties()
Gets the properties of an object included with a Change Entry.
class tests.cmislibtest.CmisClientTest(methodName='runTest')

Tests for the CmisClient class.

testCmisClient()
Instantiate a CmisClient object
testCmisClientBadAuth()
Try to instantiate a CmisClient object with bad creds
testCmisClientBadUrl()
Try to instantiate a CmisClient object with a known bad URL
testDefaultRepository()
Get the default repository by calling the repo’s service URL
testGetRepositories()
Call getRepositories and make sure at least one comes back with an ID and a name
testGetRepository()
Get a repository by repository ID
testGetRepositoryBadId()
Try to get a repository with a bad repo ID
class tests.cmislibtest.CmisTestBase(methodName='runTest')

Common ancestor class for most cmislib unit test classes.

setUp()
Create a root test folder for the test.
tearDown()
Clean up after the test.
class tests.cmislibtest.DocumentTest(methodName='runTest')

Tests for the Document class

testAllowableActions()
Create document in a test folder, then get its allowable actions
testCancelCheckout()
Create a document in a test folder, check it out, then cancel checkout
testCheckin()
Create a document in a test folder, check it out, then in
testCheckinAfterGetPWC()
Create a document in a test folder, check it out, call getPWC, then checkin
testCheckinComment()
Checkin a document with a comment
testCheckout()
Create a document in a test folder, then check it out
testCreateDocumentBinary()
Create a binary document using a file from the file system
testCreateDocumentPlain()
Create a plain document using a file from the file system
testDeleteContentStreamPWC()
Delete the content stream of a PWC
testDeleteDocument()
Create a document in a test folder, then delete it
testGetAllVersions()
Get all versions of an object
testGetLatestVersion()
Get latest version of an object
testGetProperties()
Create a document in a test folder, then get its properties
testGetPropertiesOfLatestVersion()
Get properties of latest version of an object
testSetContentStreamDoc()
Set the content stream on a doc that’s not checked out
testSetContentStreamPWC()
Set the content stream on the PWC
testUpdateProperties()
Create a document in a test folder, then update its properties
class tests.cmislibtest.FolderTest(methodName='runTest')

Tests for the Folder class

testAllowableActions()
Create a test folder, then get its allowable actions
testBadParentFolder()
Try to create a folder on a bad/bogus/deleted parent folder object
testDeleteEmptyFolder()
Create a test folder, then delete it
testDeleteNonEmptyFolder()
Create a test folder with something in it, then delete it
testGetChildren()
Get the children of the test folder
testGetDescendants()
Get the descendants of the root folder
testGetParent()
Get a folder’s parent using the getParent call
testGetProperties()
Get the root folder, then get its properties
testGetTree()
Get the folder tree of the test folder
testPropertyFilter()
Test the properties filter
testSubFolder()
Create a test folder, then create a test folder within that.
testUpdateProperties()
Create a test folder, then update its properties
class tests.cmislibtest.QueryTest(methodName='runTest')

Tests related to running CMIS queries.

setUp()
Override the base setUp to include creating a couple of test docs.
testFullText()
Find content using a full-text query
testPropertyMatch()
Find content matching cmis:name property
testScore()
Find content using FT, sorted by relevance score
testSimpleSelect()
Execute simple select star from cmis:document
testWildcardPropertyMatch()
Find content w/wildcard match on cmis:name property
class tests.cmislibtest.RepositoryTest(methodName='runTest')

Tests for the Repository class.

testCreateDocument()
Create a new ‘content-less’ document
testCreateFolder()
Create a new folder in the root folder
testGetFolder()
Create a test folder then attempt to retrieve the Folder object using its object ID
testGetObject()
Create a test folder then attempt to retrieve it as a CmisObject object using its object ID
testGetObjectBadId()
Attempt to get an object using a known bad ID
testGetObjectBadPath()
Attempt to get an object using a known bad path
testGetObjectByPath()
Create test objects (one folder, one document) then try to get them by path
testGetRootFolder()
Get the root folder of the repository
testGetUnfiledDocs()
Tests the repository’s unfiled collection
testRepositoryCapabilities()
Retrieve repository capabilities
testRepositoryInfo()
Retrieve repository info
testReturnVersion()
Get latest and latestmajor versions of an object
class tests.cmislibtest.TypeTest(methodName='runTest')

Tests for the ObjectType class (and related methods in the Repository class.

testTypeChildren()
Get the child types for this repository and make sure cmis:folder is in the list.
testTypeDefinition()
Get the cmis:document type and test a few props of the type.
testTypeDescendants()
Get the descendant types of the repository.
testTypeProperties()
Get the properties for a type.
tests.cmislibtest.isInCollection(collection, targetDoc)
Util function that searches a list of objects for a matching target object.
tests.cmislibtest.isInResultSet(resultSet, targetDoc)
Util function that searches a ResultSet for a specified target object. Note that this function will do a getNext on every page of the result set until it finds what it is looking for or reaches the end of the result set. For every item in the result set, the properties are retrieved. Long story short: this could be an expensive call.

Table Of Contents

Previous topic

Examples

Next topic

Developer Guide

This Page