Defines a signal handler for syncing an individual entity. Called when
    an entity is saved or deleted.
517366
def delete_entity_signal_handler(sender, instance, **kwargs):
    
    if instance.__class__ in entity_registry.entity_registry:
        Entity.all_objects.delete_for_obj(instance)
159014
private Entity<? extends Serializable> onAfterSave(
			Entity<? extends Serializable> entity) {
		Class<?> cls = entity.getClass();
		if (Treeable.class.isAssignableFrom(cls)) {
			Treeable self = (Treeable) entity;
			if (notNull(self.getParent())) {
				Treeable parent = (Treeable) getCurrentSession().get(cls,
						self.getParent());
				self.setPath(parent.getPath() + entity.getId().toString() + "/");
				getCurrentSession().update(self);
			}
		}
		return entity;
	}
1035822
public void refresh(Object entity)
    {
        if (contains(entity))
        {
            MainCache mainCache = (MainCache) getPersistenceCache().getMainCache();
            Node node = mainCache.getNodeFromCache(entity, getMetadata(entity.getClass()), this);
            // Locking as it might read from persistence context.

            try
            {
                lock.readLock().lock();
                node.setPersistenceDelegator(this);
                node.refresh();
            }
            finally
            {
                lock.readLock().unlock();
            }
        }
        else
        {
            throw new IllegalArgumentException("This is not a valid or managed entity, can't be refreshed");
        }
    }
653274
def defer_entity_syncing(wrapped, instance, args, kwargs):
    

    # Defer entity syncing while we run our method
    sync_entities.defer = True

    # Run the method
    try:
        return wrapped(*args, **kwargs)

    # After we run the method disable the deferred syncing
    # and sync all the entities that have been buffered to be synced
    finally:
        # Enable entity syncing again
        sync_entities.defer = False

        # Get the models that need to be synced
        model_objs = list(sync_entities.buffer.values())

        # If none is in the model objects we need to sync all
        if None in sync_entities.buffer:
            model_objs = list()

        # Sync the entities that were deferred if any
        if len(sync_entities.buffer):
            sync_entities(*model_objs)

        # Clear the buffer
        sync_entities.buffer = {}
1033813
def signal_handler(self, signum, frame):
        
        self.print_exit()
        print("\n(Terminated with signal %d)\n" % (signum))
        sys.exit(0)
1018178
public void signal(Signal signal, CmsUUID id) {

        getStatus(id).handleSignal(signal);
        runSelectionChangeAction();
    }
485844
def watchSignal(self, signal):
        
        self._extend_state()

        def signal_handler(*args, **kwargs):
            self._events_seen.append((signal, args, kwargs))
        signal.connect(signal_handler)
        if hasattr(self, 'addCleanup'):
            self.addCleanup(signal.disconnect, signal_handler)
938087
function(error) {

      // Don't connect the instance monitor if errors
      if (error) {
        return callback(error);
      }

      // Called to disconnect the listeners
      var disconnectListeners = function() {
        logger.info('disconnectLiveSync', t.className, model.toJSON());
        model.off('change', modelListener);
        model.syncMonitor.off('change', monitorListener);
        model.syncMonitor.disconnect();
        model.syncMonitor = null;
      };

      // Client-side listener - for persisting changes to the server
      var modelListener = function(changedModel, options) {
        options = options || {};

        // Don't persist unless the model is different
        if (_.isEqual(JSON.parse(JSON.stringify(model)), JSON.parse(JSON.stringify(model.syncMonitor.get('model'))))) {
          logger.info('modelListener.noChanges', t.className, model.toJSON());
          return;
        }

        // Disconnect listeners if the ID changes
        if (model.get('id') !== modelId) {
          logger.info('modelListener.alteredId', t.className, model.toJSON());
          return disconnectListeners();
        }

        // Persist changes to the server (unless the changes originated from there)
        if (!options.isSyncChanging) {
          logger.info('modelListener.saving', t.className, model.toJSON());
          model.save();
        }
      };

      // Server-side listener - for updating server changes into the model
      var monitorListener = function(changedModel, options) {

        // Don't update unless the model is different
        var newModel = model.syncMonitor.get('model');
        if (_.isEqual(JSON.parse(JSON.stringify(model)), JSON.parse(JSON.stringify(newModel)))) {
          logger.info('monitorListener.noChanges', t.className, newModel);
          return;
        }

        // Disconnect if the model was deleted or the ID isn't the same
        var isDeleted = (_.size(newModel) === 0);
        if (isDeleted || newModel.id !== modelId)  {
          logger.info('modelListener.deleted', t.className, newModel);
          disconnectListeners();
        }

        // Forward changes to the model (including server-side delete)
        var newOpts = {isSyncChanging:true};
        if (isDeleted) {
          logger.info('modelListener.deleting', t.className, newModel);
          model.clear(newOpts);
        } else {
          // Make sure the model is set to exactly the new contents (vs. override)
          logger.info('modelListener.setting', t.className, newModel);
          model.clear({silent:true});
          model.set(newModel, newOpts);
        }
      };

      // Connect the listeners
      model.on('change', modelListener);
      model.syncMonitor.on('change', monitorListener);

      // Send back the initial data model
      logger.info('connectInstanceMonitor.done', t.className, model.toJSON());
      callback(null, model.syncMonitor.get('model'));
    }
98918
function onSuccess() {
            /**
             * Make sure to clear the cache for this Entity Kind
             */
            if (_this.constructor.__hasCache(options)) {
                return _this.constructor.clearCache()
                    .then(() => _this)
                    .catch((err) => {
                        let msg = 'Error while clearing the cache after saving the entity.';
                        msg += 'The entity has been saved successfully though. ';
                        msg += 'Both the cache error and the entity saved have been attached.';
                        const cacheError = new Error(msg);
                        cacheError.__entity = _this;
                        cacheError.__cacheError = err;
                        throw cacheError;
                    });
            }

            return _this;
        }
507614
@Override
    protected void onPersist(EntityMetadata metadata, Object entity, Object id, List<RelationHolder> relationHolders)
    {
        boolean proxyRemoved = removeKunderaProxies(metadata, entity, relationHolders);

        Transaction tx = null;

        s = getStatelessSession();
        tx = onBegin();
        try
        {
            if (!isUpdate)
            {
                id = s.insert(entity);

                // Update foreign Keys
                updateForeignKeys(metadata, id, relationHolders);
                onCommit(tx);/* tx.commit(); */
            }
            else
            {
                s.update(entity);

                if (proxyRemoved)
                {
                    updateForeignKeys(metadata, id, relationHolders);
                }

                onCommit(tx);
            }
        }
        // TODO: Bad code, get rid of these exceptions, currently necessary for
        // handling many to one case
        catch (org.hibernate.exception.ConstraintViolationException e)
        {
            s.update(entity);
            log.info(e.getMessage());
            onCommit(tx);
            // tx.commit();
        }
        catch (HibernateException e)
        {
            log.error("Error while persisting object of {}, Caused by {}.", metadata.getEntityClazz(), e);
            throw new PersistenceException(e);
        }
    }
73453
public void saveAndDeleteEntities(final boolean clearOnSuccess, final I_CmsSimpleCallback<Boolean> callback) {

        final CmsEntity entity = m_entityBackend.getEntity(m_entityId);
        saveAndDeleteEntities(entity, new ArrayList<String>(m_deletedEntities), clearOnSuccess, callback);
    }
334622
def handle_data(self, context, data, dt):
        
        if self.rule.should_trigger(dt):
            self.callback(context, data)
326704
def post_save_event_listener(sender, instance, created):
    """"""
    if not instance._meta.event_ready:
        return

    if created:
        instance.create_creation_event()
    else:
        instance.create_update_event()

    # Reset the original key
    instance._original = None
75853
public void syncRecordToBase(Record recBase, Record recAlt, boolean syncSelection)
    {
        if ((recAlt != null) && (recBase != null))
        {
            recBase.moveFields(recAlt, null, true, DBConstants.READ_MOVE, false, false, true, syncSelection);
            recBase.setEditMode(recAlt.getEditMode());
        }
        if ((recBase.getEditMode() == DBConstants.EDIT_CURRENT) || (recBase.getEditMode() == DBConstants.EDIT_IN_PROGRESS))
            recBase.handleValidRecord(); // Do listeners, Display Fields
        else if (recBase.getEditMode() == DBConstants.EDIT_ADD)
            recBase.handleNewRecord(); // Do listeners, Display Fields
        //?recBase.setKeyArea(recAlt.getDefaultOrder());
    }
1279424
def keep_clean
      synchronize do
        @read_waiter.delete_unless_alive.each do |e|
          e.signal
        end
        @take_waiter.delete_unless_alive.each do |e|
          e.signal
        end
        @notify_waiter.delete_unless_alive.each do |e|
          e.notify(['close'])
        end
        @bag.delete_unless_alive.each do |e|
          notify_event('delete', e.value)
        end
      end
    end
271627
public <T> void refresh(T entity) {
        DocumentInfo documentInfo = documentsByEntity.get(entity);
        if (documentInfo == null) {
            throw new IllegalStateException("Cannot refresh a transient instance");
        }

        incrementRequestCount();

        GetDocumentsCommand command = new GetDocumentsCommand(new String[]{documentInfo.getId()}, null, false);
        _requestExecutor.execute(command, sessionInfo);

        refreshInternal(entity, command, documentInfo);
    }
854890
def delete_entity(sender, instance, **kwargs):
    """"""
    # 1 means that the last Data object is going to be deleted.
    Entity.objects.annotate(num_data=Count('data')).filter(data=instance, num_data=1).delete()