Return-Path: X-Original-To: apmail-chemistry-commits-archive@www.apache.org Delivered-To: apmail-chemistry-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 391EF98B7 for ; Mon, 12 Dec 2011 17:41:57 +0000 (UTC) Received: (qmail 27417 invoked by uid 500); 12 Dec 2011 17:41:57 -0000 Delivered-To: apmail-chemistry-commits-archive@chemistry.apache.org Received: (qmail 27372 invoked by uid 500); 12 Dec 2011 17:41:57 -0000 Mailing-List: contact commits-help@chemistry.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@chemistry.apache.org Delivered-To: mailing list commits@chemistry.apache.org Received: (qmail 27364 invoked by uid 99); 12 Dec 2011 17:41:57 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 12 Dec 2011 17:41:57 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 12 Dec 2011 17:41:43 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id A31D62388C1F for ; Mon, 12 Dec 2011 17:41:08 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: svn commit: r800171 [4/6] - in /websites/staging/chemistry/trunk/content/python/docs: ./ _sources/ _static/ Date: Mon, 12 Dec 2011 17:41:07 -0000 To: commits@chemistry.apache.org From: buildbot@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20111212174108.A31D62388C1F@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Added: websites/staging/chemistry/trunk/content/python/docs/code.html ============================================================================== --- websites/staging/chemistry/trunk/content/python/docs/code.html (added) +++ websites/staging/chemistry/trunk/content/python/docs/code.html Mon Dec 12 17:41:05 2011 @@ -0,0 +1,3568 @@ + + + + + + + + + + Code — Apache Chemistry cmislib 0.5 documentation + + + + + + + + + + + + + + + + +
+
+
+
+ +
+

Code¶

+
+

The cmislib.model Module¶

+

The cmislib.model Module contains all the CMIS domain objects. The ones you will work with are listed as top level package elements. When working with the repository, the first thing you need to do is grab an instance of cmislib.CmisClient, passing it the repository endpoint URL, username, and password.

+

For example, in Alfresco 4 and higher, the repository endpoint is +‘http://localhost:8080/alfresco/cmisatom‘. In earlier versions of +Alfresco, the endpoint is +‘http://localhost:8080/alfresco/s/api/cmis‘. In both cases, the +default username and password are ‘admin’ and ‘admin’.

+
>>> cmisClient = cmislib.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.Repository class to create new cmislib.Folder and cmislib.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, **kwargs)¶
+

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 do 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 do 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 do 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 do 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(**kwargs)¶
+

See CMIS specification document 2.2.3.5 getObjectParents

+
+
The following optional arguments are supported:
+
    +
  • filter
  • +
  • includeRelationships
  • +
  • renditionFilter
  • +
  • includeAllowableActions
  • +
  • includeRelativePathSegment
  • +
+
+
+
+ +
+
+getPaths()¶
+

Returns the object’s paths as a list of strings.

+
+ +
+
+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(sourceFolder, targetFolder)¶
+

Moves an object from the source folder to the target folder.

+

See CMIS specification document 2.2.4.13 move

+
>>> sub1 = repo.getObjectByPath('/cmislib/sub1')
+>>> sub2 = repo.getObjectByPath('/cmislib/sub2')
+>>> doc = repo.getObjectByPath('/cmislib/sub1/testdoc1')
+>>> doc.move(sub1, sub2)
+
+
+
+ +
+
+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'
+
+
+
+ +
+ +
+
+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()¶
+

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'
+
+
+
+ +
+
+getPaths()¶
+

Returns the Document’s paths by asking for the parents with the +includeRelativePathSegment flag set to true, then concats the value +of cmis:path with the relativePathSegment.

+
+ +
+
+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, contentType=None)¶
+

See CMIS specification document 2.2.4.16 setContentStream

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

A container object that can hold other CmisObject objects

+
+
+addObject(cmisObject, **kwargs)¶
+

Adds the specified object as a child of this object. No new object is +created. The repository must support multifiling for this to work.

+

See CMIS specification document 2.2.5.1 addObjectToFolder

+
>>> sub1 = repo.getObjectByPath("/cmislib/sub1")
+>>> sub2 = repo.getObjectByPath("/cmislib/sub2")
+>>> doc = sub1.createDocument("testdoc1")
+>>> len(sub1.getChildren())
+1
+>>> len(sub2.getChildren())
+0
+>>> sub2.addObject(doc)
+>>> len(sub2.getChildren())
+1
+>>> sub2.getChildren()[0].name
+u'testdoc1'
+
+
+
+
The following optional arguments are supported:
+
    +
  • allVersions
  • +
+
+
+
+ +
+
+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
  • +
+
+
+
+ +
+
+createDocumentFromString(name, properties={}, contentString=None, contentType=None, contentEncoding=None)¶
+

Creates a new document setting the content to the string provided. If +the repository supports unfiled objects, you do not have to pass in +a parent Folder otherwise it is required.

[... 2461 lines stripped ...]