expire instead of expunging

This commit is contained in:
Damien Elmes 2009-02-14 00:12:28 +09:00
parent f6b24b6d9a
commit 8892ad9f90

View file

@ -904,7 +904,6 @@ and due < :now""", now=time.time())
"Add a fact to the deck. Return list of new cards." "Add a fact to the deck. Return list of new cards."
if not fact.model: if not fact.model:
fact.model = self.currentModel fact.model = self.currentModel
fact = self.cloneFact(fact)
# validate # validate
fact.assertValid() fact.assertValid()
fact.assertUnique(self.s) fact.assertUnique(self.s)
@ -1030,15 +1029,6 @@ where facts.id not in (select factId from cards)""")
cards.append(card) cards.append(card)
return cards 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 # Cards
########################################################################## ##########################################################################
@ -1700,15 +1690,14 @@ Return new path, relative to media dir."""
"Roll back the current transaction and reset session state." "Roll back the current transaction and reset session state."
self.s.rollback() self.s.rollback()
self.s.clear() 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.update(self)
self.s.refresh(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): def openSession(self):
"Open a new session. Assumes old session is already closed." "Open a new session. Assumes old session is already closed."
self.s = SessionHelper(self.Session(), lock=self.needLock) self.s = SessionHelper(self.Session(), lock=self.needLock)