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, or a specific repository if you know the repository ID.
>>> repo = cmisClient.getDefaultRepository()
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.CmisClient(repositoryUrl, username, password)
Handles all communication with the CMIS provider.
-
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.
-
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
-
getRepository(repositoryId)
- Returns the repository identified by the specified repositoryId.
-
exception cmislib.model.CmisException
- Common base class for all exceptions.
-
class cmislib.model.CmisObject(cmisClient, repository, objectId=None, xmlDoc=None)
Common ancestor class for other CMIS domain objects such as Document and Folder.
-
applyACL(addACEs=None, removeACEs=None, ACLPropagation=None)
- See CMIS specification document 2.2.10.2 applyACL
-
applyPolicy(policyId)
- See CMIS specification document 2.2.9.1 applyPolicy
-
delete(allVersions=None)
Deletes this CmisObject from the repository.
See CMIS specification document 2.2.4.14 delete
-
getACL(onlyBasicPermissions=None)
- See CMIS specification document 2.2.10.1 getACL
-
getAllowableActions()
- See CMIS specification document 2.2.4.6 getAllowableActions
-
getAppliedPolicies()
- See CMIS specification document 2.2.9.3 getAppliedPolicies
-
getObjectId()
- Returns the object ID for this object.
-
getObjectParents(filter=None, includeRelationships=None, renditionFilter=None, includeAllowableActions=None, includeRelativePathSegment=None)
- See CMIS specification document 2.2.3.5 getObjectParents
-
getProperties(filter=None)
Returns a dict of the object’s properties. If CMIS returns an empty element for a property,
the property will be in the dict wiht a value of None.
See CMIS specification document 2.2.4.8 getProperties
-
getTitle()
- temporary
-
move(targetFolderId, sourceFolderId)
- See CMIS specification document 2.2.4.13 move
-
removePolicy(policyId)
- See CMIS specification document 2.2.9.2 removePolicy
-
updateProperties(properties, changeToken=None)
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
-
class cmislib.model.Document(cmisClient, repository, objectId=None, xmlDoc=None)
An object typically associated with file content.
-
cancelCheckout()
- See CMIS specification document 2.2.7.2 cancelCheckOut
-
checkin(major=None, properties=None, contentStream=None, checkinComment=None, policies=None, addACEs=None, removeACEs=None)
Checks in this Document which must be a private working copy (PWC).
See CMIS specification document 2.2.7.3 checkIn
-
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
-
deleteContentStream(changeToken=None)
- See CMIS specification document 2.2.4.17 deleteContentStream
-
getAllVersions(filter=None, includeAllowableActions=None)
- See CMIS specification document 2.2.7.5 getAllVersions
-
getContentStream(streamId=None)
Returns the CMIS service response from invoking the ‘enclosure’ link.
See CMIS specification document 2.2.4.10 getContentStream
-
getLatestVersion(major=None, filter=None, includeRelationships=None, includePolicyIds=None, renditionFilter=None, includeACL=None, includeAllowableActions=None)
- See CMIS specification document 2.2.7.4 getObjectOfLatestVersion
-
getPropertiesOfLatestVersion(major=None, filter=None)
- See CMIS specification document 2.2.7.4 getPropertiesOfLatestVersion
-
getRelationships(includeSubRelationshipTypes=None, relationshipDirection=None, typeId=None, maxItems=None, skipCount=None, filter=None, includeAllowableActions=None)
- See CMIS specification document 2.2.8.1 getObjectRelationships
-
getRenditions(renditionFilter=None, maxItems=None, skipCount=None)
- See CMIS specification document 2.2.4.11 getRenditions
-
setContentStream(contentStream, overwriteFlag=None, changeToken=None)
- See CMIS specification document 2.2.4.16 setContentStream
-
class cmislib.model.Folder(cmisClient, repository, objectId=None, xmlDoc=None)
A container object that can hold other CmisObject objects
-
addObject(cmisObject, allVersions=None)
- See CMIS specification document 2.2.5.1 addObjectToFolder
-
createDocument(properties, file=None, versioningState=None, policies=None, addACEs=None, removeACEs=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.
-
createFolder(properties, policies=None, addACEs=None, removeACEs=None)
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)
See CMIS specification document 2.2.4.3 createFolder
-
deleteTree(allVersions=None)
- See CMIS specification document 2.2.4.15 deleteTree
-
getChildren(maxItems=None, skipCount=None, orderBy=None, filter=None, includeRelationships=None, renditionFilter=None, includeAllowableActions=None, includePathSegment=None)
Returns a list of CmisObjects for each child of the Folder.
See CMIS specification document 2.2.3.1 getChildren
-
getDescendants(depth=None, filter=None, includeRelationships=None, renditionFilter=None, includeAllowableActions=None, includePathSegment=None)
Gets the descendants of this folder.
See CMIS specification document 2.2.3.2 getDescendants
-
getDescendantsLink()
- Returns the ‘down’ link of type CMIS_TREE_TYPE
-
getParent(filter=None)
- See CMIS specification document 2.2.3.4 getFolderParent
-
getTree(depth=None, filter=None, includeRelationships=None, renditionFilter=None, includeAllowableActions=None, includePathSegment=None)
- See CMIS specification document 2.2.3.3 getFolderTree
-
removeObject(cmisObject)
- 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.
-
getLink(rel, type)
Gets the HREF for the link element with the specified rel and type.
<link rel=”down”
href=”http://localhost:8080/alfresco/s/cmis/type/cmis:document/children”
type=”application/atom+xml;type=feed” />
<link rel=”down”
href=”http://localhost:8080/alfresco/s/cmis/type/cmis:document/descendants”
type=”application/cmistree+xml” />
-
getTypeId()
- Returns the type ID for this object.
-
class cmislib.model.Policy(repository, objectId)
- An arbirary object that can ‘applied’ to objects that the repository identifies as being ‘controllable’.
-
class cmislib.model.Relationship(repository, objectId)
- Defines a relationship object between two CmisObjects objects
-
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
-
createDocument(properties, parentFolder=None, file=None, versioningState=None, policies=None, addACEs=None, removeACEs=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 file, pass in a file object.
See CMIS specification document 2.2.4.1 createDocument
-
createDocumentFromSource(sourceId, properties=None, folderId=None, versioningState=None, policies=None, addACEs=None, removeACEs=None)
- See CMIS specification document 2.2.4.2 createDocumentFromSource
-
createFolder(properties, parentFolder, policies=None, addACEs=None, removeACEs=None)
Creates a new Folder object in the specified parent.
See CMIS specification document 2.2.4.3 createFolder
-
createPolicy(properties, folderId=None, policies=None, addACEs=None, removeACEs=None)
- See CMIS specification document 2.2.4.5 createPolicy
-
createRelationship(properties, policies=None, addACEs=None, removeACEs=None)
- See CMIS specification document 2.2.4.4 createRelationship
-
getCapabilities()
- Returns a dict of repository capabilities.
-
getCheckedOutDocs(folderId=None, maxItems=None, skipCount=None, orderBy=None, filter=None, includeRelationships=None, renditionFilter=None, includeAllowableActions=None)
Returns a collection of CmisObject objects that are currently checked out.
See CMIS specification document 2.2.3.6 getCheckedOutDocs
-
getCollection(collectionType)
- Returns a list of CmisObject objects returned for the specified collection.
-
getCollectionLink(collectionType)
- Returns the link HREF from the specified collectionType (‘checkedout’, for example).
-
getContentChanges(changeLogToken=None, includeProperties=None, includePolicyIds=None, includeACL=None, maxItems=None)
- See CMIS specification document 2.2.6.2 getContentChanges
-
getFolder(folderId)
- Returns a Folder object for a specified folderId
-
getObject(objectId, filter=None, includeRelationships=None, includePolicyIds=None, renditionFilter=None, includeACL=None, includeAllowableActions=None)
Returns an object given the specified object ID.
See CMIS specification document 2.2.4.7 getObject
-
getObjectByPath(path, filter=None, includeAllowableActions=None)
Returns an object given the path to the object.
See CMIS specification document 2.2.4.9 getObjectByPath
-
getRepositoryId()
- Returns this repository’s unique identifier
-
getRepositoryInfo()
Returns a dict of repository information.
See CMIS specification document 2.2.2.2 getRepositoryInfo
-
getRepositoryName()
- Returns this repository’s name
-
getTypeChildren(typeId=None, includePropertyDefinitions=None, maxItems=None, skipCount=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
-
getTypeDefinition(typeId)
Returns an ObjectType object for the specified object type id.
See CMIS specification document 2.2.2.5 getTypeDefinition
-
getTypeDefinitions()
- Returns a list of ObjectType objects representing the base types in the repository.
-
getTypeDescendants(typeId=None, depth=None, includePropertyDefinitions=None)
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
-
getUriTemplates()
- Returns a list of the URI templates the repository service knows about.
-
query(statement, searchAllVersions=None, includeRelationships=None, renditionFilter=None, includeAllowableActions=None, maxItems=None, skipCount=None)
Returns a list of CmisObject objects based on the CMIS Query Language passed in as the statement.
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 *”.
See CMIS specification document 2.2.6.1 query
-
cmislib.model.multiple_replace(dict, 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/
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