def create_group(group_name): ent = model.AuthGroup(key=model.group_key(group_name), members=imported_groups[group_name], created_ts=timestamp, created_by=auth.get_service_self_identity(), modified_ts=timestamp, modified_by=auth.get_service_self_identity()) to_put.append(ent)
def create_group(group_name): ent = model.AuthGroup( key=model.group_key(group_name), members=imported_groups[group_name], created_ts=timestamp, created_by=auth.get_service_self_identity(), modified_ts=timestamp, modified_by=auth.get_service_self_identity()) to_put.append(ent)
def config_fetcher(): conf = cls.fetch() if not conf: conf = cls() conf.set_defaults() conf.store(updated_by=auth.get_service_self_identity()) return conf
def clear_group(group_name): ent = system_groups[group_name] if ent.members: ent.members = [] ent.modified_ts = timestamp ent.modified_by = auth.get_service_self_identity() to_put.append(ent)
def update_group(group_name): existing = system_groups[group_name] imported = imported_groups[group_name] if existing.members != imported: existing.members = imported existing.modified_ts = timestamp existing.modified_by = auth.get_service_self_identity() to_put.append(existing)
def write_config(text, config_revision=None, modified_by=None): """Validates config text blobs and puts it into the datastore. Raises: ValueError on invalid format. """ validate_config(text) e = GroupImporterConfig(key=config_key(), config_proto=text, config_revision=config_revision, modified_by=modified_by or auth.get_service_self_identity()) e.put()
def write_config(text, config_revision=None, modified_by=None): """Validates config text blobs and puts it into the datastore. Raises: ValueError on invalid format. """ validate_config(text) e = GroupImporterConfig( key=config_key(), config=read_legacy_config(), config_proto=text, config_revision=config_revision, modified_by=modified_by or auth.get_service_self_identity()) e.put()
def fetcher(): with fetcher.cache_lock: expiry = fetcher.cache_expiry if expiry is not None and utils.utcnow() < expiry: raise ndb.Return(fetcher.cache_value) # Do not lock while yielding, it would cause deadlock. # Also do not cache a future, it might cross ndb context boundary. # If there is no cached value, multiple concurrent requests will make # multiple RPCs, but as soon as one of them updates cache, subsequent # requests will use the cached value, for a minute. conf = yield cls.fetch_async() if not conf: conf = cls() conf.set_defaults() yield conf.store_async(updated_by=auth.get_service_self_identity()) with fetcher.cache_lock: fetcher.cache_expiry = utils.utcnow() + datetime.timedelta(minutes=1) fetcher.cache_value = conf raise ndb.Return(conf)