@tornado.gen.coroutine
    def resolve_dirty(self, ent):
        """Write back (or delete) a single dirty entry. Then mark it clean.
        """
        dbname = ent.tup[0]
        if dbname not in writable_collections:
            # Maybe we should update the equivalent writable entry here,
            # but we'll just skip it.
            self.log.warning('Unable to update %s entry: %s', dbname, ent.key)
            if ent.mutable:
                ent.origval = deepcopy(ent.val)
            return

        if ent.found:
            # Resolve update.
            try:
                checkwritable(ent.val)
            except __HOLE__ as ex:
                self.log.warning('Unable to update %s entry: %s', ent.key, ex)
                ### drop entry entirely?
                return
            newval = dict(ent.query)
            newval['val'] = ent.val
            yield motor.Op(self.app.mongodb[dbname].update,
                           ent.query, newval,
                           upsert=True)
            if ent.mutable:
                ent.origval = deepcopy(ent.val)
        else:
            # Resolve delete.
            yield motor.Op(self.app.mongodb[dbname].remove,
                           ent.query)
        ent.dirty = False
dataset/ETHPy150Open erkyrath/tworld/lib/two/propcache.py/PropCache.resolve_dirty