This is brett's Typepad Profile.
Join Typepad and start following brett's activity
Join Now!
Already a member? Sign In
Recent Activity
Use a piece of this to define sync() for yourself, and you should be good to go. Just make sure to do sync() after the transaction finishes (using a closure, or something): class MyModel(db.Model): foo = db.IntegerProperty(default=0) def add_one(self): python_scoping_is_annoying = [None] def txn(): new = python_scoping_is_annoying[0] = db.get(self.key()) += 1 new.put() db.run_in_transaction(txn) new = python_scoping_is_annoying[0] # Copy all new values over to this instance. for k in + new.dynamic_properties(): setattr(self, k, getattr(new, k)) a = MyModel() a.put() print a.key(), a.add_one() print a.key(), a.add_one() print a.key(), Output: agVzaGVsbHIPCxIHTXlNb2RlbBjKqwUM 0 agVzaGVsbHIPCxIHTXlNb2RlbBjKqwUM 1 agVzaGVsbHIPCxIHTXlNb2RlbBjKqwUM 2
1 reply