def txn(): if key is not None: if utils.key_exists(key): raise IntegrityError( "Tried to INSERT with existing key") id_or_name = key.id_or_name() if isinstance(id_or_name, basestring) and id_or_name.startswith("__"): raise NotSupportedError( "Datastore ids cannot start with __. Id was %s" % id_or_name) if not constraints.constraint_checks_enabled(self.model): # Fast path, just insert results.append(datastore.Put(ent)) else: markers = constraints.acquire(self.model, ent) try: results.append(datastore.Put(ent)) if not was_in_transaction: # We can cache if we weren't in a transaction before this little nested one caching.add_entity_to_cache( self.model, ent, caching.CachingSituation.DATASTORE_GET_PUT) except: # Make sure we delete any created markers before we re-raise constraints.release_markers(markers) raise
def txn(): if key is not None: if utils.key_exists(key): raise IntegrityError("Tried to INSERT with existing key") id_or_name = key.id_or_name() if isinstance(id_or_name, basestring) and id_or_name.startswith("__"): raise NotSupportedError("Datastore ids cannot start with __. Id was %s" % id_or_name) if not constraints.constraint_checks_enabled(self.model): # Fast path, just insert results.append(datastore.Put(ent)) else: markers = constraints.acquire(self.model, ent) try: results.append(datastore.Put(ent)) if not was_in_transaction: # We can cache if we weren't in a transaction before this little nested one caching.add_entities_to_cache( self.model, [ent], caching.CachingSituation.DATASTORE_GET_PUT, self.namespace, ) except: # Make sure we delete any created markers before we re-raise constraints.release_markers(markers) raise
def txn(): for key in keys: if check_existence and key is not None: if utils.key_exists(key): raise IntegrityError("Tried to INSERT with existing key") id_or_name = key.id_or_name() if isinstance(id_or_name, basestring) and id_or_name.startswith("__"): raise NotSupportedError("Datastore ids cannot start with __. Id was %s" % id_or_name) # Notify App Engine of any keys we're specifying intentionally reserve_id(key.kind(), key.id_or_name(), self.namespace) results = datastore.Put(entities) for entity in entities: markers.extend(constraints.acquire(self.model, entity)) caching.add_entities_to_cache( self.model, entities, caching.CachingSituation.DATASTORE_GET_PUT, self.namespace, skip_memcache=True ) return results
def txn(): for key in keys: if check_existence and key is not None: if utils.key_exists(key): raise IntegrityError("Tried to INSERT with existing key") id_or_name = key.id_or_name() if isinstance(id_or_name, six.string_types) and id_or_name.startswith("__"): raise NotSupportedError("Datastore ids cannot start with __. Id was %s" % id_or_name) # Notify App Engine of any keys we're specifying intentionally reserve_id(key.kind(), key.id_or_name(), self.namespace) results = perform_insert(entities) for entity, _ in entities: markers.extend(constraints.acquire(self.model, entity)) caching.add_entities_to_cache( self.model, [x[0] for x in entities], caching.CachingSituation.DATASTORE_GET_PUT, self.namespace, skip_memcache=True ) return results
def txn(): if key is not None: if utils.key_exists(key): raise IntegrityError("Tried to INSERT with existing key") markers = constraints.acquire(self.model, ent) try: results.append(datastore.Put(ent)) except: #Make sure we delete any created markers before we re-raise constraints.release_markers(markers) raise entity_post_insert.send(sender=self.model, entity=ent)
def txn(): if key is not None: if utils.key_exists(key): raise IntegrityError("Tried to INSERT with existing key") id_or_name = key.id_or_name() if isinstance(id_or_name, basestring) and id_or_name.startswith("__"): raise NotSupportedError("Datastore ids cannot start with __. Id was %s" % id_or_name) markers = constraints.acquire(self.model, ent) try: results.append(datastore.Put(ent)) caching.add_entity_to_context_cache(self.model, ent) except: #Make sure we delete any created markers before we re-raise constraints.release_markers(markers) raise