def refresh ( self , document ) : try : old_cache_size = self . cache_size self . cache_size = 0 obj = self . query ( type ( document ) ) . filter_by ( mongo_id = document . mongo_id ) . one ( ) finally : self . cache_size = old_cache_size self . cache_write ( obj ) return obj
design db memory cache python
Load a new copy of a document from the database . does not replace the old one
def refresh(self, document):
		""" Load a new copy of a document from the database.  does not
			replace the old one """
		try:
			old_cache_size = self.cache_size
			self.cache_size = 0
			obj = self.query(type(document)).filter_by(mongo_id=document.mongo_id).one()
		finally:
			self.cache_size = old_cache_size
		self.cache_write(obj)
		return obj