Hi GAE web2py users,

I ran into an issue today where i need to have atomic inserts into a GAE 
table.  in a normal database you can do a read/write lock and check if a row 
exists before you insert, and/or put unique constraints on columns to make 
this happen.  in GAE you can't.

the right answer on how to do this is 
here: 
http://code.google.com/appengine/docs/python/datastore/modelclass.html#Model_get_or_insert
and it assumes that you can generate a string key that would be predictable 
on multiple insert attempts.  (in my case i can)

now, i'd love to be able to use that with web2py, but web2py expects that 
all IDs are integers.  i think that a way to enhance DAL to work with this 
might be to:
 - use GAE reference properties for reference 
fields: 
http://code.google.com/appengine/docs/python/datastore/typesandpropertyclasses.html#ReferenceProperty
 - allow user to set the GAE named key when they want to, otherwise let DAL 
and GAE assign an int ID
 - come up with a way (inside or outside of DAL) that allows us to use the 
get_or_insert() method of GAE models when desired.

before i dig into trying to create a patch for review, are there thoughts, 
concerns, gotchas, or other things i should think about?

thanks much for your time!

christian

Reply via email to