fix detached sqlalchemy object
This commit is contained in:
parent
137f6e050f
commit
5117bd7782
1 changed files with 6 additions and 0 deletions
|
@ -134,6 +134,7 @@ class UpdateInfo(BaseModel):
|
|||
|
||||
@app.post("/api/update/{recid}")
|
||||
async def update(recid: int, req: UpdateInfo):
|
||||
global db
|
||||
newrec = {}
|
||||
newrec["starttime"] = date_read(req.starttime)
|
||||
newrec["endtime"] = date_read(req.endtime)
|
||||
|
@ -143,6 +144,8 @@ async def update(recid: int, req: UpdateInfo):
|
|||
try:
|
||||
logger.info("prima di update")
|
||||
result_rec = db.update(recid, newrec)
|
||||
session = db.get_session(rec)
|
||||
session.refresh(rec)
|
||||
logger.info("dopo update")
|
||||
except Exception as exc:
|
||||
return rec_err("Errore Aggiornamento", exception=exc)
|
||||
|
@ -160,8 +163,11 @@ class GenerateResponse(BaseModel):
|
|||
|
||||
@app.post("/api/generate/{recid}")
|
||||
async def generate(recid: int, response: Response, background_tasks: BackgroundTasks):
|
||||
global db
|
||||
# prendiamo la rec in causa
|
||||
rec = db._search(_id=recid)[0]
|
||||
session = db.get_session(rec)
|
||||
session.refresh(rec)
|
||||
if rec.ready:
|
||||
return {
|
||||
"status": "ready",
|
||||
|
|
Loading…
Reference in a new issue