def create(self, callback):
        assert self._callback is None
        self._callback = callback

        fruit = Fruit(fruit_id=uuid.uuid4().hex, fruit=Fruit.get_random_fruit())

        ap = AsyncFruitPersister(fruit)
        ap.persist(self._on_persist_done)
Exemple #2
0
    def create(self, callback):
        assert self._callback is None
        self._callback = callback

        fruit = Fruit(fruit_id=uuid.uuid4().hex,
                      fruit=Fruit.get_random_fruit())

        ap = AsyncFruitPersister(fruit)
        ap.persist(self._on_persist_done)
    def _on_fetch_done(self, is_ok, fruit, afr):
        if not is_ok:
            self._call_callback(False)
            return

        if fruit is None:
            self._call_callback(True)
            return

        new_fruit = afr.async_state
        if not new_fruit:
            new_fruit = Fruit.get_random_fruit()

        fruit.change_fruit(new_fruit)

        afp = AsyncFruitPersister(fruit)
        afp.persist(self._on_persist_done)
Exemple #4
0
    def _on_fetch_done(self, is_ok, fruit, afr):
        if not is_ok:
            self._call_callback(False)
            return

        if fruit is None:
            self._call_callback(True)
            return

        new_fruit = afr.async_state
        if not new_fruit:
            new_fruit = Fruit.get_random_fruit()

        fruit.change_fruit(new_fruit)

        afp = AsyncFruitPersister(fruit)
        afp.persist(self._on_persist_done)