Is there an alternative way/strategy which could be used to achieve the same as provided "transaction" in GAE Python?
In GAE, "Transaction" helps ensure that all the NDB operations inside a transaction succeed or all are rolled back.
I cannot use "transaction" at many places in my code, where I feel it is needed, due to the entity group count limit of 5(xg).
Appreciate your time.
One of the use cases
class A(ndb.Model):
:: # Some Properties
class B(ndb.Model):
:: # Some Properties
class C(ndb.Model):
:: # Some Properties
class D(ndb.Model):
:: # Some Properties
class E(ndb.Model):
:: # Some Properties
class F(ndb.Model):
:: # Some Properties
class G(ndb.Model):
:: # Some Properties
class create_new_x (BaseRequestHandler):
@ndb.toplevel
def get(self):
::
a1 = A (id="x", p1=v1, .. , pn=vn)
a1.put_async ()
b1 = B (id="y", p1=v1, .. , pn=vn)
b1.put_async ()
::
g1 = G (id="z", p1=v1, .. , pn=vn)
g1.put_async ()
return
When I create a new entity (say, "A1") of Model "A", I also create entities (say, "B1", "C1", D1", "E1", "F1", "G1") of Models "B", "C", "D", "E", "F", "G" in the same user request. I do not want to assign a parent for entities "B1", "C1", D1", "E1", "F1", "G1". If I assign them parent (as "A1"), then I would have to first get "A1" whenever I want to get any of "B1", "C1", D1", "E1", "F1", "G1". This is because we need to specify the ancestor key in "get_by_id".