class CmisClient(object): """ Handles all communication with the CMIS provider. """ def __init__(self, repositoryUrl, username, password, **kwargs): """ This is the entry point to the API. You need to know the :param repositoryUrl: The service URL of the CMIS provider :param username: Username :param password: Password >>> client = CmisClient('http://localhost:8080/alfresco/s/cmis', 'admin', 'admin') """ self.repositoryUrl = repositoryUrl self.username = username self.password = password self.extArgs = kwargs if kwargs.has_key('binding') and (isinstance(kwargs['binding'], Binding)): self.binding = kwargs['binding'] else: self.binding = AtomPubBinding(**kwargs) self.logger = logging.getLogger('cmislib.model.CmisClient') self.logger.info('Creating an instance of CmisClient') def __str__(self): """To string""" return 'CMIS client connection to %s' % self.repositoryUrl def getRepositories(self): """ Returns a dict of high-level info about the repositories available at this service. The dict contains entries for 'repositoryId' and 'repositoryName'. >>> client.getRepositories() [{'repositoryName': u'Main Repository', 'repositoryId': u'83beb297-a6fa-4ac5-844b-98c871c0eea9'}] """ return self.binding.getRepositoryService().getRepositories(self) def getRepository(self, repositoryId): """ Returns the repository identified by the specified repositoryId. >>> repo = client.getRepository('83beb297-a6fa-4ac5-844b-98c871c0eea9') >>> repo.getRepositoryName() u'Main Repository' """ return self.binding.getRepositoryService().getRepository(self, repositoryId) def getDefaultRepository(self): """ 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' """ return self.binding.getRepositoryService().getDefaultRepository(self) defaultRepository = property(getDefaultRepository) repositories = property(getRepositories)
class CmisClient(object): """ Handles all communication with the CMIS provider. """ def __init__(self, repositoryUrl, username, password, **kwargs): """ This is the entry point to the API. You need to know the :param repositoryUrl: The service URL of the CMIS provider :param username: Username :param password: Password >>> client = CmisClient('http://localhost:8080/alfresco/s/cmis', 'admin', 'admin') """ self.repositoryUrl = repositoryUrl self.username = username self.password = password self.extArgs = kwargs if kwargs.has_key("binding") and (isinstance(kwargs["binding"], Binding)): self.binding = kwargs["binding"] else: self.binding = AtomPubBinding(**kwargs) self.logger = logging.getLogger("cmislib.model.CmisClient") self.logger.info("Creating an instance of CmisClient") def __str__(self): """To string""" return "CMIS client connection to %s" % self.repositoryUrl def getRepositories(self): """ Returns a dict of high-level info about the repositories available at this service. The dict contains entries for 'repositoryId' and 'repositoryName'. >>> client.getRepositories() [{'repositoryName': u'Main Repository', 'repositoryId': u'83beb297-a6fa-4ac5-844b-98c871c0eea9'}] """ return self.binding.getRepositoryService().getRepositories(self) def getRepository(self, repositoryId): """ Returns the repository identified by the specified repositoryId. >>> repo = client.getRepository('83beb297-a6fa-4ac5-844b-98c871c0eea9') >>> repo.getRepositoryName() u'Main Repository' """ return self.binding.getRepositoryService().getRepository(self, repositoryId) def getDefaultRepository(self): """ 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' """ return self.binding.getRepositoryService().getDefaultRepository(self) defaultRepository = property(getDefaultRepository) repositories = property(getRepositories)
class CmisClient(object): """ Handles all communication with the CMIS provider. """ def __init__(self, repositoryUrl, username, password, **kwargs): """ This is the entry point to the API. You need to know the :param repositoryUrl: The service URL of the CMIS provider :param username: Username :param password: Password >>> client = CmisClient( ... 'http://localhost:8080/alfresco/s/cmis', 'admin', 'admin') """ self.repositoryUrl = repositoryUrl self.username = username self.password = password self.extArgs = kwargs self.session = requests.session() self.session.auth = (self.username, self.password) self.session.hooks = {'response': self._check_response_status} if 'binding' in kwargs and (isinstance(kwargs['binding'], Binding)): self.binding = kwargs['binding'] else: self.binding = AtomPubBinding(**kwargs) self.logger = logging.getLogger('cmislib.model.CmisClient') self.logger.debug('Creating an instance of CmisClient') def __str__(self): """To string""" return 'CMIS client connection to %s' % self.repositoryUrl def _check_response_status(self, response, *ags, **kwargs): """ A callback function called by 'requests' after a call to the cmis container :param response: the response object :param ags: :param kwargs: :return: """ if not response.ok: self.binding._processCommonErrors(response) def getRepositories(self): """ Returns a dict of high-level info about the repositories available at this service. The dict contains entries for 'repositoryId' and 'repositoryName'. >>> client.getRepositories() [{'repositoryName': u'Main Repository', 'repositoryId': u'83beb297-a6fa-4ac5-844b-98c871c0eea9'}] """ return self.binding.getRepositoryService().getRepositories(self) def getRepository(self, repositoryId): """ Returns the repository identified by the specified repositoryId. >>> repo = client.getRepository('83beb297-a6fa-4ac5-844b-98c871c0eea9') >>> repo.getRepositoryName() u'Main Repository' """ return self.binding.getRepositoryService().getRepository( self, repositoryId) def getDefaultRepository(self): """ 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' """ return self.binding.getRepositoryService().getDefaultRepository(self) defaultRepository = property(getDefaultRepository) repositories = property(getRepositories)