chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jpo...@apache.org
Subject svn commit: r1027775 - in /incubator/chemistry/cmislib/trunk/src: cmislib.egg-info/SOURCES.txt cmislib/model.py tests/cmislibtest.py tests/settings.py
Date Tue, 26 Oct 2010 23:47:03 GMT
Author: jpotts
Date: Tue Oct 26 23:47:03 2010
New Revision: 1027775

URL: http://svn.apache.org/viewvc?rev=1027775&view=rev
Log:
Support for extended args on CmisClient constructor per CMIS-263

Modified:
    incubator/chemistry/cmislib/trunk/src/cmislib.egg-info/SOURCES.txt
    incubator/chemistry/cmislib/trunk/src/cmislib/model.py
    incubator/chemistry/cmislib/trunk/src/tests/cmislibtest.py
    incubator/chemistry/cmislib/trunk/src/tests/settings.py

Modified: incubator/chemistry/cmislib/trunk/src/cmislib.egg-info/SOURCES.txt
URL: http://svn.apache.org/viewvc/incubator/chemistry/cmislib/trunk/src/cmislib.egg-info/SOURCES.txt?rev=1027775&r1=1027774&r2=1027775&view=diff
==============================================================================
--- incubator/chemistry/cmislib/trunk/src/cmislib.egg-info/SOURCES.txt (original)
+++ incubator/chemistry/cmislib/trunk/src/cmislib.egg-info/SOURCES.txt Tue Oct 26 23:47:03
2010
@@ -4,6 +4,8 @@ NOTICE.txt
 README.txt
 setup.cfg
 setup.py
+dist/hash-sign.sh
+dist/release.sh
 src/cmislib/__init__.py
 src/cmislib/exceptions.py
 src/cmislib/messages.py

Modified: incubator/chemistry/cmislib/trunk/src/cmislib/model.py
URL: http://svn.apache.org/viewvc/incubator/chemistry/cmislib/trunk/src/cmislib/model.py?rev=1027775&r1=1027774&r2=1027775&view=diff
==============================================================================
--- incubator/chemistry/cmislib/trunk/src/cmislib/model.py (original)
+++ incubator/chemistry/cmislib/trunk/src/cmislib/model.py Tue Oct 26 23:47:03 2010
@@ -88,7 +88,7 @@ class CmisClient(object):
     Handles all communication with the CMIS provider.
     """
 
-    def __init__(self, repositoryUrl, username, password):
+    def __init__(self, repositoryUrl, username, password, **kwargs):
 
         """
         This is the entry point to the API. You need to know the
@@ -102,6 +102,7 @@ class CmisClient(object):
         self.repositoryUrl = repositoryUrl
         self.username = username
         self.password = password
+        self.extArgs = kwargs
 
     def __str__(self):
         """To string"""
@@ -120,7 +121,7 @@ class CmisClient(object):
         [{'repositoryName': u'Main Repository', 'repositoryId': u'83beb297-a6fa-4ac5-844b-98c871c0eea9'}]
         """
 
-        result = self.get(self.repositoryUrl)
+        result = self.get(self.repositoryUrl, **self.extArgs)
         if (type(result) == HTTPError):
             raise RuntimeException()
 
@@ -146,7 +147,7 @@ class CmisClient(object):
         u'Main Repository'
         """
 
-        doc = self.get(self.repositoryUrl)
+        doc = self.get(self.repositoryUrl, **self.extArgs)
         workspaceElements = doc.getElementsByTagNameNS(APP_NS, 'workspace')
 
         for workspaceElement in workspaceElements:
@@ -168,7 +169,7 @@ class CmisClient(object):
         u'83beb297-a6fa-4ac5-844b-98c871c0eea9'
         """
 
-        doc = self.get(self.repositoryUrl)
+        doc = self.get(self.repositoryUrl, **self.extArgs)
         workspaceElements = doc.getElementsByTagNameNS(APP_NS, 'workspace')
         # instantiate a Repository object with the first workspace
         # element we find
@@ -188,6 +189,10 @@ class CmisClient(object):
         there.
         """
 
+        # merge the cmis client extended args with the ones that got passed in
+        if (len(self.extArgs) > 0):
+            kwargs.update(self.extArgs)
+
         result = Rest().get(url,
                             username=self.username,
                             password=self.password,
@@ -208,6 +213,10 @@ class CmisClient(object):
         to delete a document you'd call :class:`Document.delete`.
         """
 
+        # merge the cmis client extended args with the ones that got passed in
+        if (len(self.extArgs) > 0):
+            kwargs.update(self.extArgs)
+
         result = Rest().delete(url,
                                username=self.username,
                                password=self.password,
@@ -229,6 +238,10 @@ class CmisClient(object):
         been checked out, you'd call :class:`Document.checkin` on the PWC.
         """
 
+        # merge the cmis client extended args with the ones that got passed in
+        if (len(self.extArgs) > 0):
+            kwargs.update(self.extArgs)
+
         result = Rest().post(url,
                              payload,
                              contentType,
@@ -254,6 +267,10 @@ class CmisClient(object):
         been checked out, you'd call :class:`Document.checkin` on the PWC.
         """
 
+        # merge the cmis client extended args with the ones that got passed in
+        if (len(self.extArgs) > 0):
+            kwargs.update(self.extArgs)
+
         result = Rest().put(url,
                             payload,
                             contentType,
@@ -2536,7 +2553,8 @@ class Document(CmisObject):
             # the cmis client class parses non-error responses
             result = Rest().get(srcUrl,
                                 username=self._cmisClient.username,
-                                password=self._cmisClient.password)
+                                password=self._cmisClient.password,
+                                **self._cmisClient.extArgs)
             if result.code != 200:
                 raise CmisException(result.code)
             return result

Modified: incubator/chemistry/cmislib/trunk/src/tests/cmislibtest.py
URL: http://svn.apache.org/viewvc/incubator/chemistry/cmislib/trunk/src/tests/cmislibtest.py?rev=1027775&r1=1027774&r2=1027775&view=diff
==============================================================================
--- incubator/chemistry/cmislib/trunk/src/tests/cmislibtest.py (original)
+++ incubator/chemistry/cmislib/trunk/src/tests/cmislibtest.py Tue Oct 26 23:47:03 2010
@@ -41,7 +41,7 @@ class CmisTestBase(unittest.TestCase):
 
     def setUp(self):
         """ Create a root test folder for the test. """
-        self._cmisClient = CmisClient(settings.REPOSITORY_URL, settings.USERNAME, settings.PASSWORD)
+        self._cmisClient = CmisClient(settings.REPOSITORY_URL, settings.USERNAME, settings.PASSWORD,
**settings.EXT_ARGS)
         self._repo = self._cmisClient.getDefaultRepository()
         self._rootFolder = self._repo.getObjectByPath(TEST_ROOT_PATH)
         self._folderName = " ".join(['cmislib', self.__class__.__name__, str(time())])
@@ -58,14 +58,14 @@ class CmisClientTest(unittest.TestCase):
 
     def testCmisClient(self):
         '''Instantiate a CmisClient object'''
-        cmisClient = CmisClient(settings.REPOSITORY_URL, settings.USERNAME, settings.PASSWORD)
+        cmisClient = CmisClient(settings.REPOSITORY_URL, settings.USERNAME, settings.PASSWORD,
**settings.EXT_ARGS)
         self.assert_(cmisClient != None)
 
     def testGetRepositories(self):
         '''Call getRepositories and make sure at least one comes back with
         an ID and a name
         '''
-        cmisClient = CmisClient(settings.REPOSITORY_URL, settings.USERNAME, settings.PASSWORD)
+        cmisClient = CmisClient(settings.REPOSITORY_URL, settings.USERNAME, settings.PASSWORD,
**settings.EXT_ARGS)
         repoInfo = cmisClient.getRepositories()
         self.assert_(len(repoInfo) >= 1)
         self.assert_('repositoryId' in repoInfo[0])
@@ -73,14 +73,14 @@ class CmisClientTest(unittest.TestCase):
 
     def testDefaultRepository(self):
         '''Get the default repository by calling the repo's service URL'''
-        cmisClient = CmisClient(settings.REPOSITORY_URL, settings.USERNAME, settings.PASSWORD)
+        cmisClient = CmisClient(settings.REPOSITORY_URL, settings.USERNAME, settings.PASSWORD,
**settings.EXT_ARGS)
         repo = cmisClient.getDefaultRepository()
         self.assert_(repo != None)
         self.assert_(repo.getRepositoryId() != None)
 
     def testGetRepository(self):
         '''Get a repository by repository ID'''
-        cmisClient = CmisClient(settings.REPOSITORY_URL, settings.USERNAME, settings.PASSWORD)
+        cmisClient = CmisClient(settings.REPOSITORY_URL, settings.USERNAME, settings.PASSWORD,
**settings.EXT_ARGS)
         repo = cmisClient.getDefaultRepository()
         defaultRepoId = repo.getRepositoryId()
         defaultRepoName = repo.getRepositoryName()
@@ -91,7 +91,7 @@ class CmisClientTest(unittest.TestCase):
     # Error conditions
     def testCmisClientBadUrl(self):
         '''Try to instantiate a CmisClient object with a known bad URL'''
-        cmisClient = CmisClient(settings.REPOSITORY_URL + 'foobar', settings.USERNAME, settings.PASSWORD)
+        cmisClient = CmisClient(settings.REPOSITORY_URL + 'foobar', settings.USERNAME, settings.PASSWORD,
**settings.EXT_ARGS)
         self.assertRaises(CmisException, cmisClient.getRepositories)
 
     def testCmisClientBadAuth(self):
@@ -102,7 +102,7 @@ class CmisClientTest(unittest.TestCase):
 
     def testGetRepositoryBadId(self):
         '''Try to get a repository with a bad repo ID'''
-        cmisClient = CmisClient(settings.REPOSITORY_URL, settings.USERNAME, settings.PASSWORD)
+        cmisClient = CmisClient(settings.REPOSITORY_URL, settings.USERNAME, settings.PASSWORD,
**settings.EXT_ARGS)
         self.assertRaises(ObjectNotFoundException,
                           cmisClient.getRepository,
                           '123FOO')
@@ -1061,7 +1061,7 @@ class TypeTest(unittest.TestCase):
     def testTypeDescendants(self):
         '''Get the descendant types of the repository.'''
 
-        cmisClient = CmisClient(settings.REPOSITORY_URL, settings.USERNAME, settings.PASSWORD)
+        cmisClient = CmisClient(settings.REPOSITORY_URL, settings.USERNAME, settings.PASSWORD,
**settings.EXT_ARGS)
         repo = cmisClient.getDefaultRepository()
         typeDefs = repo.getTypeDescendants()
         folderDef = None
@@ -1079,7 +1079,7 @@ class TypeTest(unittest.TestCase):
         #This test would be more interesting if there was a standard way to
         #deploy a custom model. Then we could look for custom types.
 
-        cmisClient = CmisClient(settings.REPOSITORY_URL, settings.USERNAME, settings.PASSWORD)
+        cmisClient = CmisClient(settings.REPOSITORY_URL, settings.USERNAME, settings.PASSWORD,
**settings.EXT_ARGS)
         repo = cmisClient.getDefaultRepository()
         typeDefs = repo.getTypeChildren()
         folderDef = None
@@ -1092,7 +1092,7 @@ class TypeTest(unittest.TestCase):
 
     def testTypeDefinition(self):
         '''Get the cmis:document type and test a few props of the type.'''
-        cmisClient = CmisClient(settings.REPOSITORY_URL, settings.USERNAME, settings.PASSWORD)
+        cmisClient = CmisClient(settings.REPOSITORY_URL, settings.USERNAME, settings.PASSWORD,
**settings.EXT_ARGS)
         repo = cmisClient.getDefaultRepository()
         docTypeDef = repo.getTypeDefinition('cmis:document')
         self.assertEquals('cmis:document', docTypeDef.getTypeId())
@@ -1100,7 +1100,7 @@ class TypeTest(unittest.TestCase):
 
     def testTypeProperties(self):
         '''Get the properties for a type.'''
-        cmisClient = CmisClient(settings.REPOSITORY_URL, settings.USERNAME, settings.PASSWORD)
+        cmisClient = CmisClient(settings.REPOSITORY_URL, settings.USERNAME, settings.PASSWORD,
**settings.EXT_ARGS)
         repo = cmisClient.getDefaultRepository()
         docTypeDef = repo.getTypeDefinition('cmis:document')
         self.assertEquals('cmis:document', docTypeDef.getTypeId())

Modified: incubator/chemistry/cmislib/trunk/src/tests/settings.py
URL: http://svn.apache.org/viewvc/incubator/chemistry/cmislib/trunk/src/tests/settings.py?rev=1027775&r1=1027774&r2=1027775&view=diff
==============================================================================
--- incubator/chemistry/cmislib/trunk/src/tests/settings.py (original)
+++ incubator/chemistry/cmislib/trunk/src/tests/settings.py Tue Oct 26 23:47:03 2010
@@ -19,7 +19,7 @@
 #REPOSITORY_URL = 'http://cmis.alfresco.com/s/cmis'
 #REPOSITORY_URL = 'http://localhost:8080/cmis/repository' # Apache Chemistry
 #REPOSITORY_URL = 'http://cmis.dnsdojo.com:8080/p8cmis/resources/DaphneA/Service'
-REPOSITORY_URL = 'http://localhost:8080/alfresco/s/cmis'  # Alfresco
+REPOSITORY_URL = 'http://localhost:8080/alfresco/s/api/cmis'  # Alfresco
 #REPOSITORY_URL = 'http://cmis.demo.nuxeo.org/nuxeo/site/cmis/repository'
 #REPOSITORY_URL = 'http://localhost:8080/opencmis/atom'  # OpenCMIS from the OpenText guys
 #REPOSITORY_URL = 'http://ec2-174-129-218-67.compute-1.amazonaws.com/cmis/atom' #OpenText
on Amazon
@@ -32,10 +32,12 @@ PASSWORD = 'admin'
 #PASSWORD = 'Administrator'  # Nuxeo
 #USERNAME = 'cmisuser'
 #PASSWORD = 'otcmis'
+EXT_ARGS = {}
+#EXT_ARGS = {'alf_ticket': 'TICKET_cef29079d8d5341338bf372b08278bc30ec89380'}
 # Absolute path to a directory where test folders can be created, including
 # the trailing slash.
 #TEST_ROOT_PATH = '/default-domain/jeff test'  # No trailing slash
-TEST_ROOT_PATH = '/cmislib test'  # No trailing slash
+TEST_ROOT_PATH = '/cmislib'  # No trailing slash
 #TEST_ROOT_PATH = '/'
 # Binary test files. Assumed to exist in the same dir as this python script
 TEST_BINARY_1 = '250px-Cmis_logo.png'



Mime
View raw message