juliankmazo / webapp-improved

Automatically exported from code.google.com/p/webapp-improved
Other
0 stars 0 forks source link

auth: Rollback Unique DS entries if user.put() fails #82

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Create a user model that will fail when put() is called on it. E.g.:

class CustomUser(webapp2_extras.appengine.auth.models.User):
  has_error = ndb.StringProperty(default=False)

2. call 

ok, user = CustomUser.create_user('some_fake_auth_id')

3. the line "user.put()" in create_user 
http://webapp-improved.appspot.com/_modules/webapp2_extras/appengine/auth/models
.html#User.create_user
will fail. 

4. The Unique datastore will hold an entry for CustomUser with 
'some_fake_auth_id', but CustomUser will be empty, because user creation failed.

What version of the product are you using? On what operating system?
App Engine / Python
- name: webapp2
  version: "2.5.1"

Please provide any additional information below.
Though this example the error is clearly on the programmer's side in providing 
a model that won't allow for it to be saved, there are other sources of errors 
(DeadLineExceededError e.g.) that will cause user.put() to fail. I think in 
that case, webapp2 should handle this scenario gracefully and rollback the 
changes it made to the Unique datastore.

Original issue reported on code.google.com by al...@pagewoo.com on 18 Jul 2013 at 6:28