def set_alternative(self, identity, test_name, alternative):
        # XXX: possible race condition, but one will win, and
        # for A/B testing that's probably OK.
        result = self.results.find_one({'i': identity, 't': test_name})
        if not result:
            self.results.save({'i': identity, 't': test_name, 'n': alternative, 's': []})

        elif result and result['n'] != alternative:
            raise Exception('different alternative already set for identity %s' % identity)
dataset/ETHPy150Open dcrosta/dabble/dabble/backends/mongodb.py/MongoResultStorage.set_alternative/original