def get_item_for_atomid()

in atomresponder/vs_mixin.py [0:0]


    def get_item_for_atomid(self, atomid):
        """
        Returns a populated VSItem object for the master, or None if no such item exists
        :param atomid:
        :return:
        """
        try:
            item = VSItem(url=settings.VIDISPINE_URL, user=settings.VIDISPINE_USERNAME,passwd=settings.VIDISPINE_PASSWORD)
            item.populate(atomid)   # this will work if the item has an external id set to the atom id.
                                    #this is done in `create_placeholder_for_atomid`
            return item
        except VSNotFound:
            s = VSItemSearch(url=settings.VIDISPINE_URL,user=settings.VIDISPINE_USERNAME,passwd=settings.VIDISPINE_PASSWORD)
            s.addCriterion({const.GNM_DELIVERABLE_ATOM_ID: atomid, const.GNM_ASSET_CATEGORY: 'Deliverable'})
            result = s.execute()
            if result.totalItems==0:
                return None
            elif result.totalItems==1:
                return next(result.results(shouldPopulate=True))
            else:
                resultList = [item for item in result.results(shouldPopulate=False)]
                potential_master_ids = [item.name for item in resultList]
                logger.warning("Multiple masters returned for atom ID {0}: {1}. Using the first.".format(atomid, potential_master_ids))
                resultList[0].populate(resultList[0].name)
                return resultList[0]