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}")
|
@app.post("/api/update/{recid}")
|
||||||
async def update(recid: int, req: UpdateInfo):
|
async def update(recid: int, req: UpdateInfo):
|
||||||
|
global db
|
||||||
newrec = {}
|
newrec = {}
|
||||||
newrec["starttime"] = date_read(req.starttime)
|
newrec["starttime"] = date_read(req.starttime)
|
||||||
newrec["endtime"] = date_read(req.endtime)
|
newrec["endtime"] = date_read(req.endtime)
|
||||||
|
@ -143,6 +144,8 @@ async def update(recid: int, req: UpdateInfo):
|
||||||
try:
|
try:
|
||||||
logger.info("prima di update")
|
logger.info("prima di update")
|
||||||
result_rec = db.update(recid, newrec)
|
result_rec = db.update(recid, newrec)
|
||||||
|
session = db.get_session(rec)
|
||||||
|
session.refresh(rec)
|
||||||
logger.info("dopo update")
|
logger.info("dopo update")
|
||||||
except Exception as exc:
|
except Exception as exc:
|
||||||
return rec_err("Errore Aggiornamento", exception=exc)
|
return rec_err("Errore Aggiornamento", exception=exc)
|
||||||
|
@ -160,8 +163,11 @@ class GenerateResponse(BaseModel):
|
||||||
|
|
||||||
@app.post("/api/generate/{recid}")
|
@app.post("/api/generate/{recid}")
|
||||||
async def generate(recid: int, response: Response, background_tasks: BackgroundTasks):
|
async def generate(recid: int, response: Response, background_tasks: BackgroundTasks):
|
||||||
|
global db
|
||||||
# prendiamo la rec in causa
|
# prendiamo la rec in causa
|
||||||
rec = db._search(_id=recid)[0]
|
rec = db._search(_id=recid)[0]
|
||||||
|
session = db.get_session(rec)
|
||||||
|
session.refresh(rec)
|
||||||
if rec.ready:
|
if rec.ready:
|
||||||
return {
|
return {
|
||||||
"status": "ready",
|
"status": "ready",
|
||||||
|
|
Loading…
Reference in a new issue