class indexed(): def __init__(self, settings): self.db=DB(settings.database) self.settings=settings self.index_name=settings.index def __enter__(self): self.db=DB(self.settings.database) return self def __exit__(self, type, value, traceback): if isinstance(value, BaseException): self.db.rollback() self.db.close() return try: self.db.commit() except Exception, e: Log.warning(u"can not commit()", e) finally:
def __enter__(self): self.db=DB(self.settings.database) return self
def __init__(self, settings): self.db=DB(settings.database) self.settings=settings self.index_name=settings.index