> We will add a special API to handle single record transactions but
> there is nothing we can do about the fact that GAE does not provide
> real transactions.

In that case, update_record() must handle aborted transaction errors
and return value (True/False) that indicates whether the update was
actually performed:

Inside the driver it would look like this:

def update_record(table_obj,attrs):
  if [k for k in attrs if isinstance(attrs[k],type(lambda x: x))]:
    try:
       def update_record_txn(table_obj,attrs):
         record = table_obj.get_by_id(attrs.id)
         for k,v in attrs:
           if isinstance(v,type(lambda x: x)):
             v = v(record)
           setattr(record,k,v)
         record.put()
         return record
       row = google_db.run_in_transaction
(update_record_txn,table_obj,attrs)
    except  google_exc.TransactionFailedError,e:
      return False
  else: ...
  return True


Used like this:

if not row.update_record(count=lambda r: r.count+1):
  let_app_deal_with_failed_transaction(row)

The row.update_record(...) return value can be ignored too, but if you
are using lambdas then you should be checking that return value.

Robin

On Jan 18, 10:14 am, mdipierro <mdipie...@cs.depaul.edu> wrote:
> Let's clarify this once more.
>
> GAE supports transactions ONLY at the level of one entity group (for
> practical purposes, transactions involving one single record). They
> are not the normal transactions of a SQL database.
>
> We will add a special API to handle single record transactions but
> there is nothing we can do about the fact that GAE does not provide
> real transactions.
>
> This is a big limitation of GAE and it is due to the fact that they
> distribute queries on BigTables.
>
> Massimo
>
> On Jan 18, 8:38 am, Robin B <robi...@gmail.com> wrote:
>
> > > Sorry, I don't quite understand.  Would implementing GAE transactions
> > > result in a change to how we call on the DAL?
>
> > Yes.
>
> > The proposal mentioned above is explained 
> > here:http://groups.google.com/group/web2py/browse_thread/thread/293fe4c58f...
>
> > We can provide both notations:
> >   1) row.update_record(count=db.table.count+1)
> >   2) row.update_record(count=lambda r: r.count+1)
>
> > db.table.count+1 and lambda r: r.count+1 is nice syntax for atomically
> > updating a single record, but it does not make it easy for the
> > application handle transaction failures in a cross driver way.  Also
> > if you want access to the full power of appengine transactions which
> > is required to create locks, create_or_insert/unique-constraints,
> > create/read/update/delete other records in the same entity group, it
> > should not be done in an update_record lamda.
>
> > To get the full power of appengine transactions, you would need:
>
> > txn = db.build_transaction(mytxn)
>
> > which allows you to create/read/update/delete other records in the
> > same entity group and handle transaction failures in a consistent way.
>
> > Robin
>
> > > P.S. the more I work with Google Big Table, the more I'm finding it
> > > very crippled... (and crippling in terms of development difficulty)
>
> > It might feel like more difficultly up front, but you gain complete
> > scalability, so you do not have to rewrite things later on to scale.
>
> > If you want to experience real development difficulty, you could try
> > designing/configuring/operating a multi-master relational database,
> > now that is painful!  ;)
>
> > Robin
>
> > On Jan 18, 8:11 am, Jonathan Benn <jonathan.b...@gmail.com> wrote:
>
> > > Hi Robin,
>
> > > On Jan 18, 3:30 pm, Robin B <robi...@gmail.com> wrote:
>
> > > > Calling the txn(...) returns whether the txn suceeded or failed, so
> > > > you do not have to handle any custom exceptions outside the dal.  For
> > > > SQLDB the txn(...) will allways return True.
>
> > > Sorry, I don't quite understand.  Would implementing GAE transactions
> > > result in a change to how we call on the DAL?
>
> > > P.S. the more I work with Google Big Table, the more I'm finding it
> > > very crippled... (and crippling in terms of development difficulty)
>
> > > --Jonathan
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to