Example #1
0
 def apply_import(revision, entities_to_put, keys_to_delete):
   """Transactionally puts and deletes a bunch of entities."""
   # DB changed between transactions, retry.
   if auth.get_auth_db_revision() != revision:
     return False
   # Apply mutations, bump revision number.
   futures = []
   futures.extend(ndb.put_multi_async(entities_to_put))
   futures.extend(ndb.delete_multi_async(keys_to_delete))
   ndb.Future.wait_all(futures)
   if any(f.get_exception() for f in futures):
     raise ndb.Rollback()
   auth.replicate_auth_db()
   return True
Example #2
0
 def apply_import(revision, entities_to_put, keys_to_delete):
     """Transactionally puts and deletes a bunch of entities."""
     # DB changed between transactions, retry.
     if auth.get_auth_db_revision() != revision:
         return False
     # Apply mutations, bump revision number.
     futures = []
     futures.extend(ndb.put_multi_async(entities_to_put))
     futures.extend(ndb.delete_multi_async(keys_to_delete))
     ndb.Future.wait_all(futures)
     if any(f.get_exception() for f in futures):
         raise ndb.Rollback()
     auth.replicate_auth_db()
     return True
Example #3
0
 def apply_import(revision, entities_to_put, entities_to_delete, ts):
     """Transactionally puts and deletes a bunch of entities."""
     # DB changed between transactions, retry.
     if auth.get_auth_db_revision() != revision:
         return False
     # Apply mutations, bump revision number.
     for e in entities_to_put:
         e.record_revision(modified_by=model.get_service_self_identity(),
                           modified_ts=ts,
                           comment='External group import')
     for e in entities_to_delete:
         e.record_deletion(modified_by=model.get_service_self_identity(),
                           modified_ts=ts,
                           comment='External group import')
     futures = []
     futures.extend(ndb.put_multi_async(entities_to_put))
     futures.extend(
         ndb.delete_multi_async(e.key for e in entities_to_delete))
     for f in futures:
         f.check_success()
     auth.replicate_auth_db()
     return True
Example #4
0
 def apply_import(revision, entities_to_put, entities_to_delete, ts):
   """Transactionally puts and deletes a bunch of entities."""
   # DB changed between transactions, retry.
   if auth.get_auth_db_revision() != revision:
     return False
   # Apply mutations, bump revision number.
   for e in entities_to_put:
     e.record_revision(
         modified_by=model.get_service_self_identity(),
         modified_ts=ts,
         comment='External group import')
   for e in entities_to_delete:
     e.record_deletion(
         modified_by=model.get_service_self_identity(),
         modified_ts=ts,
         comment='External group import')
   futures = []
   futures.extend(ndb.put_multi_async(entities_to_put))
   futures.extend(ndb.delete_multi_async(e.key for e in entities_to_delete))
   for f in futures:
     f.check_success()
   auth.replicate_auth_db()
   return True
Example #5
0
 def snapshot_groups():
     """Fetches all existing groups and AuthDB revision number."""
     groups = model.AuthGroup.query(ancestor=model.root_key()).fetch_async()
     return auth.get_auth_db_revision(), groups.get_result()
Example #6
0
 def snapshot_groups():
   """Fetches all existing groups and AuthDB revision number."""
   groups = model.AuthGroup.query(ancestor=model.root_key()).fetch_async()
   return auth.get_auth_db_revision(), groups.get_result()