The "insert" method returns the id of the inserted row.
The "update_or_insert" method returns the id of the inserted row, but
returns None in case of an update...

Why is it so?

I have a case in which I want to update_or_insert and then further
update the corresponding row (to track the status of a long running
process).
I would rather have the method to always output the id of the updated/
inserted row...
Or is there any use-case you would like to discriminate between the
fact you inserted or update a row?

What do you think?

  -Olivier


>From dal.py (I added the proposed modification)
===========

def update_or_insert(self, key=DEFAULT, **values):
  if key==DEFAULT:
    record = self(**values)
  else:
    record = self(key)
   if record:
    record.update_record(**values)
    newid = None  #------> why not record['id'] ????
   else:
     newid = self.insert(**values)
   return newid

Reply via email to