diff --git a/anki/deck.py b/anki/deck.py index 621718f26..bcd6d1d28 100644 --- a/anki/deck.py +++ b/anki/deck.py @@ -904,7 +904,6 @@ and due < :now""", now=time.time()) "Add a fact to the deck. Return list of new cards." if not fact.model: fact.model = self.currentModel - fact = self.cloneFact(fact) # validate fact.assertValid() fact.assertUnique(self.s) @@ -1030,15 +1029,6 @@ where facts.id not in (select factId from cards)""") cards.append(card) return cards - def cloneFact(self, oldFact): - "Copy fact into new session." - model = self.s.query(Model).get(oldFact.model.id) - fact = self.newFact(model) - for field in fact.fields: - fact[field.name] = oldFact[field.name] - fact.tags = oldFact.tags - return fact - # Cards ########################################################################## @@ -1700,15 +1690,14 @@ Return new path, relative to media dir.""" "Roll back the current transaction and reset session state." self.s.rollback() self.s.clear() - self.refresh() - - def refresh(self): - "Flush, invalidate all objects from cache and reload." - self.s.flush() - self.s.clear() self.s.update(self) self.s.refresh(self) + def refresh(self): + "Flush and expire all items from the session." + self.s.flush() + self.s.expire_all() + def openSession(self): "Open a new session. Assumes old session is already closed." self.s = SessionHelper(self.Session(), lock=self.needLock)