On Fri, 13 Apr 2012 11:38:25 -0700 (PDT), sababa.sab...@gmail.com said: > The > function should only add periods that doesn't overlap any of the > already registered ones.
Let me try to help (I owe this group a lot of help). I've ignored your code, and I don't know what schema you're using, but here's the pseudo and untested code: def should_this_period_be_inserted(start,end): # Check that all periods that started before this one # also finished before this one started q = ((db.period.begindate<start)&(db.period.enddate>start)) if db(query).count(): return False # Check that no periods started while this one was in progress q = ((db.period.begindate>=start)&(db.period.begindate<=end)) if db(query).count(): return False # If we got this far, the period didn't overlap return True Have I understood what you're trying to do? -- "You can have everything in life you want if you help enough other people get what they want" - Zig Ziglar. Who did you help today?