FIX db session managing
It's not fully fixed yet, probably. This fixes the bug in generate() that prevents filename to be added.
This commit is contained in:
parent
0a1b6f4392
commit
c0de3679a4
2 changed files with 8 additions and 9 deletions
|
@ -164,7 +164,7 @@ class RecAPI(Bottle):
|
||||||
'time': rec.starttime.strftime('%y%m%d_%H%M'),
|
'time': rec.starttime.strftime('%y%m%d_%H%M'),
|
||||||
'name': filter(lambda c: c.isalpha(), rec.name)
|
'name': filter(lambda c: c.isalpha(), rec.name)
|
||||||
}
|
}
|
||||||
self.db.update(rec.id, rec.serialize())
|
self.db.get_session(rec).commit()
|
||||||
job_id = self._app.pq.submit(
|
job_id = self._app.pq.submit(
|
||||||
create_mp3,
|
create_mp3,
|
||||||
start=rec.starttime,
|
start=rec.starttime,
|
||||||
|
|
|
@ -15,10 +15,6 @@ from config_manager import get_config
|
||||||
|
|
||||||
PAGESIZE = 10
|
PAGESIZE = 10
|
||||||
|
|
||||||
"""
|
|
||||||
This class describe a single Record (Rec() class) and the
|
|
||||||
records manager (RecDB() class)
|
|
||||||
"""
|
|
||||||
Base = declarative_base()
|
Base = declarative_base()
|
||||||
|
|
||||||
|
|
||||||
|
@ -99,7 +95,7 @@ class RecDB:
|
||||||
_rlist[0].name = rec["name"]
|
_rlist[0].name = rec["name"]
|
||||||
self.log.debug("DB:: Update: data AFTER %s" % _rlist[0])
|
self.log.debug("DB:: Update: data AFTER %s" % _rlist[0])
|
||||||
|
|
||||||
inspect(_rlist[0]).session.commit()
|
self.get_session(_rlist[0]).commit()
|
||||||
self.log.debug("DB:: Update complete")
|
self.log.debug("DB:: Update complete")
|
||||||
return _rlist[0]
|
return _rlist[0]
|
||||||
|
|
||||||
|
@ -127,9 +123,12 @@ class RecDB:
|
||||||
logging.info("DB: Commit!!")
|
logging.info("DB: Commit!!")
|
||||||
self.session.commit()
|
self.session.commit()
|
||||||
|
|
||||||
def get_session(self):
|
def get_session(self, rec=None):
|
||||||
|
if rec is None:
|
||||||
Session = sessionmaker(bind=self.engine)
|
Session = sessionmaker(bind=self.engine)
|
||||||
return Session()
|
return Session()
|
||||||
|
else:
|
||||||
|
return inspect(rec).session
|
||||||
|
|
||||||
def get_all(self, page=0, page_size=PAGESIZE):
|
def get_all(self, page=0, page_size=PAGESIZE):
|
||||||
return self._search(page=page, page_size=page_size)
|
return self._search(page=page, page_size=page_size)
|
||||||
|
|
Loading…
Reference in a new issue