'Store this job and all its items in the job table'

def store(self):

    db = current.db
    self.__define_tables()
    jobtable = self.job_table
    query = (jobtable.job_id == self.job_id)
    row = db(query).select(jobtable.id, limitby=(0, 1)).first()
    if row:
        record_id = row.id
    else:
        record_id = None
    record = Storage(job_id=self.job_id)
    try:
        tablename = self.table._tablename
    except:
        pass
    else:
        record.update(tablename=tablename)
    for item in self.items.values():
        item.store(item_table=self.item_table)
    if record_id:
        db((jobtable.id == record_id)).update(**record)
    else:
        record_id = jobtable.insert(**record)
    return record_id
