Setup the model events
323455
public static function boot()
    {
        parent::boot();

        self::saving(function($model)
        {
            return $model->beforeSave();
        });

        self::saved(function($model)
        {
            return $model->afterSave();
        });

        self::deleting(function($model)
        {
            return $model->beforeDelete();
        });

        self::deleted(function($model)
        {
            return $model->afterDelete();
        });
    }
386294
def setup_figcanvas(self):
        """"""
        self.figcanvas = FigureCanvas(background_color=self.background_color)
        self.figcanvas.installEventFilter(self)
        self.setWidget(self.figcanvas)
699608
public function setup() {

		$this->struct['modal'] = $this->get_base();
		$this->config();
		$this->struct['modal']['config']['view'] = $this->struct['modal']['config']['template'];
		unset( $this->struct['modal']['config']['template'] );
		add_action( 'uix_control_item_submit_' . $this->slug, $this->struct['modal']['config']['callback'], 100 );
		parent::setup();
		$this->set_submit();
	}
7164
def add_event(options)
      self.events ||= []
      event = EventAssertion.new
      event.add_value(options)
      self.events << event
    end
147715
def set_event(self, ref, tk_event, callback):
        
        # has an EventCallback been created for this tk event
        if tk_event not in self._event_callbacks:
            self._event_callbacks[tk_event] = EventCallback(self._widget, self._tks, tk_event)

        # assign this ref to this event callback
        self._refs[ref] = self._event_callbacks[tk_event]

        # set up the callback
        self._refs[ref].set_callback(ref, callback)
640085
def setModel(self, model):
        ""
        self._model = model
        self.ui.aofsSpnbx.setValue(model.samplerate())
1004697
public function triggerModels($name, ModelEvent $event = null)
    {
        if ($event === null) {
            $event = new ModelEvent();
        }
        foreach ($this->models as $model) {
            $model->trigger($name, $event);
        }

        return $event->isValid;
    }
1137307
function Process(model, pid) {
    if (model === undefined)
      throw new Error('model must be provided');
    if (pid === undefined)
      throw new Error('pid must be provided');
    tr.model.ProcessBase.call(this, model);
    this.pid = pid;
    this.name = undefined;
    this.labels = [];
    this.instantEvents = [];
    this.memoryDumps = [];
    this.frames = [];
    this.activities = [];
  }
930118
def setModel(self, model):
        
        self.paramList.setModel(model)
        model.hintRequested.connect(self.hintRequested)
        model.rowsInserted.connect(self.updateTitle)
        model.rowsRemoved.connect(self.updateTitle)
        self.updateTitle()
813950
public function after_setup_theme(): void {

		foreach ( $this->event_configs as $config ) {
			$this->add_events( $config->get_events() );
		}
	}
509434
def _setup_events(plugin):
    

    events = plugin.events

    if events and isinstance(events, (list, tuple)):
        for event in [e for e in events if e in _EVENT_VALS]:
            register('event', event, plugin)
1006784
public function add_events()
    {

        // Internal Authentication Events
        $this->app->events->listen(LoginEvent::class, Login::class);
        $this->app->events->listen(LogoutEvent::class, Logout::class);
        $this->app->events->listen(Attempting::class, Attempt::class);

        // Custom Events
        $this->app->events->listen('security.log', SecLog::class);
    }
421247
public void setup() {
        JadeAgentIntrospector.getMyInstance(this);
        LogActivator.logToFile(logger, this.getName(), Level.ALL);
        this.template = MessageTemplate.MatchAll();
        addBehaviour(new RequestServer());
    }
1065633
def prepare_model(self, sess, allow_initialize=True):
    """"""
    if self._follower:
      self.wait_for_initialization()
    else:
      self._init_model(sess, allow_initialize)

    if sess is not self._sess:
      if self.threads:
        raise ValueError('You must call stop_queues() before '
                         'starting a new session with QueueRunners.')
      self._sess = sess
    self._start_threads(sess)
991826
protected static function bootSlugUniqueModels()
    {
        // on model's creating and updating event
        foreach (['creating', 'updating'] as $event) {
            static::$event(function ($model) use ($event) {
                // if custom build slug from column not set
                if (!property_exists($model, 'buildSlugFrom')) {
                    $model->setSlugAttribute($model->title);
                }
                else { // use specified column
                    $column = $model->buildSlugFrom;
                    $model->setSlugAttribute($model->{$column});
                }
            });
        }
    }
314641
def run(self):
        '''
        
        '''

        # Parse the stdin into a global event object
        stdin = self.read_stdin()
        self.event = self.read_event(stdin)

        # Prepare global settings
        self.settings = get_settings()
        self.api_settings = self.get_api_settings()

        # Prepare command line arguments and
        self.parser = argparse.ArgumentParser()

        # set up the 2.x to 1.x event mapping argument
        self.parser.add_argument("--map-v2-event-into-v1",
                                 action="store_true",
                                 default=False,
                                 dest="v2event")

        if hasattr(self, 'setup'):
            self.setup()
        (self.options, self.remain) = self.parser.parse_known_args()

        # map the event if required
        if (self.options.v2event or
                os.environ.get("SENSU_MAP_V2_EVENT_INTO_V1")):
            self.event = map_v2_event_into_v1(self.event)

        # Filter (deprecated) and handle
        self.filter()
        self.handle()
1183142
function onCreating(model, attrs, options) {
            if (!model.get('author_id')) {
                if (model.get('authors')) {
                    model.set('author_id', model.get('authors')[0].id);
                } else {
                    model.set('author_id', this.contextUser(options));
                }
            }

            if (!model.get('authors')) {
                model.set('authors', [{
                    id: model.get('author_id')
                }]);
            }

            return this._handleOptions('onCreating')(model, attrs, options);
        }