Your code shoudl wrok except that I would replace (db.MyLogs.iteration_max.belongs(finished_tasks)).__invert__()
with ~(db.MyLogs.iteration_max.belongs(finished_tasks)) what error do you get? On May 31, 8:37 am, till <[email protected]> wrote: > Hi all, > > I having some issues using the "belongs" function of the DAL. > > I'm trying to get the entry of the logs that has had no entry with > logtype==3 yet on the current "iteration_max", but only one or more > entries with logtype==10 and a timestamp that is older than the > timeout in seconds, given with "myTimeout". > > Is there any way to get this working? > > thanks in advance! > > [code] > myID=0 # some dummy ID... > finished_tasks = db((db.MyLogs.run== myID) & > (db.MyLogs.logtype==3))._select(db.MyLogs.iteration_max) > import datetime > timeout = datetime.datetime.now() > timeout = timeout-datetime.timedelta(seconds=myTimeout) > unfinished_tasks = db((db.MyLogs.run== myID) & > (db.MyLogs.timestamp>timeout) &(db.MyLogs.logtype==10) & > ((db.MyLogs.iteration_max.belongs(finished_tasks)).__invert__() ) > ).select(db.MyLogs.iteration_max,orderby=db.MyLogs.iteration_max,limitby=(0,1)) > [/code]

