예제 #1
0
    def getCompaniesForProject(self, project_id):
        """Get companies on project
        
        REST: GET /projects/#{project_id}/companies.xml

        Returns a list of all companies associated with given project.
        
        Response:
            <companies>
                <company>
                    ...
                </company>
                <company>
                    ...
                </company>
                ...
                </company>
            </companies>
        """
        # ensure that we got numerical project id
        assert isinstance(project_id, int)
        
        path = '/projects/%d/companies.xml'
        response = self.get(path)
        if response.status == 404:
            raise NotFoundError, 'Project with %d id is not found!' % project_id
        
        rootElement = self.fromXML(response.contents)
        # TODO: use special Array attribute
        companies = []
        for data in rootElement.getElementsByTagName('company'):
            companies.append(Company.load(data))
        return companies
예제 #2
0
    def getCompanies(self):
        """Get companies
        
        REST: GET /companies.xml

        Returns a list of all companies visible to the requesting user.
        
        Response:
            <companies>
                <company>
                    ...
                </company>
                <company>
                    ...
                </company>
                ...
                </company>
            </companies>
        """
        path = '/companies.xml'
        rootElement = self.fromXML(self.get(path).contents)
        # TODO: use special Array attribute
        companies = []
        for data in rootElement.getElementsByTagName('company'):
            companies.append(Company.load(data))
        return companies
예제 #3
0
파일: basecamp.py 프로젝트: BurnzZ/banana
    def getCompaniesForProject(self, project_id):
        """Get companies on project
        
        REST: GET /projects/#{project_id}/companies.xml

        Returns a list of all companies associated with given project.
        
        Response:
            <companies>
                <company>
                    ...
                </company>
                <company>
                    ...
                </company>
                ...
                </company>
            </companies>
        """
        # ensure that we got numerical project id
        assert isinstance(project_id, int)

        path = '/projects/%d/companies.xml'
        response = self.get(path)
        if response.status == 404:
            raise NotFoundError, 'Project with %d id is not found!' % project_id

        rootElement = self.fromXML(response.contents)
        # TODO: use special Array attribute
        companies = []
        for data in rootElement.getElementsByTagName('company'):
            companies.append(Company.load(data))
        return companies
예제 #4
0
파일: basecamp.py 프로젝트: BurnzZ/banana
    def getCompanies(self):
        """Get companies
        
        REST: GET /companies.xml

        Returns a list of all companies visible to the requesting user.
        
        Response:
            <companies>
                <company>
                    ...
                </company>
                <company>
                    ...
                </company>
                ...
                </company>
            </companies>
        """
        path = '/companies.xml'
        rootElement = self.fromXML(self.get(path).contents)
        # TODO: use special Array attribute
        companies = []
        for data in rootElement.getElementsByTagName('company'):
            companies.append(Company.load(data))
        return companies
예제 #5
0
    def getCompanyById(self, company_id):
        """Get company
        
        REST: GET /companies/#{company_id}.xml

        Returns a single company identified by its integer ID.
        
        Response:
            <company>
                <id type="integer">1</id>
                <name>Globex Corporation</name>
            </company>
        """
        # ensure that we got numerical company id
        assert isinstance(company_id, int)
        
        path = '/companies/%d.xml' % company_id
        response = self.get(path)
        if response.status == 404:
            raise NotFoundError, 'Company with %d id is not found!' % company_id
        
        rootElement = self.fromXML(response.contents)
        return Company.load(rootElement)
예제 #6
0
파일: basecamp.py 프로젝트: BurnzZ/banana
    def getCompanyById(self, company_id):
        """Get company
        
        REST: GET /companies/#{company_id}.xml

        Returns a single company identified by its integer ID.
        
        Response:
            <company>
                <id type="integer">1</id>
                <name>Globex Corporation</name>
            </company>
        """
        # ensure that we got numerical company id
        assert isinstance(company_id, int)

        path = '/companies/%d.xml' % company_id
        response = self.get(path)
        if response.status == 404:
            raise NotFoundError, 'Company with %d id is not found!' % company_id

        rootElement = self.fromXML(response.contents)
        return Company.load(rootElement)