Creates a menu entry for given model data.
        Updates results in place.

        Args:
            model_data: Model data.
            object_type: Relation name.
            results: Results dict.
17244
def _add_crud(self, model_data, object_type, results):
        
        model = model_registry.get_model(model_data['name'])
        field_name = model_data.get('field')
        verbose_name = model_data.get('verbose_name', model.Meta.verbose_name_plural)
        category = model_data.get('category', settings.DEFAULT_OBJECT_CATEGORY_NAME)
        wf_dict = {"text": verbose_name,
                   "wf": model_data.get('wf', "crud"),
                   "model": model_data['name'],
                   "kategori": category}
        if field_name:
            wf_dict['param'] = field_name
        results[object_type].append(wf_dict)
        self._add_to_quick_menu(wf_dict['model'], wf_dict)
165348
def update(self, **data):
        
        data = data.items()
        update_command_arg = ", ".join("{} = ?".format(entry[0])
                                       for entry in data)
        cmd = "update {table} set {update_command_arg} {where_clause}".format(
            update_command_arg=update_command_arg,
            where_clause=self.where_clause,
            table=self.table_name).rstrip()
        Repo.db.execute(cmd, [entry[1] for entry in data] + self.where_values)
554873
def _update_internal_data_base(self):
        

        model = self.model

        # print("clean data base")

        ### FOR COMBOS
        # internal transitions
        # - take all internal states
        # - take all not used internal outcomes of this states

        # external transitions
        # - take all external states
        # - take all external outcomes
        # - take all not used own outcomes

        ### LINKING
        # internal  -> transition_id -> from_state = outcome combos
        #           -> ...
        # external -> state -> outcome combos
        self.combo['internal'] = {}
        self.combo['external'] = {}
        self.combo['free_from_states'] = {}
        self.combo['free_from_outcomes_dict'] = {}
        self.combo['free_ext_from_outcomes_dict'] = {}
        self.combo['free_ext_from_outcomes_dict'] = {}

        if isinstance(model, ContainerStateModel):
            # check for internal combos
            for transition_id, transition in model.state.transitions.items():
                self.combo['internal'][transition_id] = {}

                [from_state_combo, from_outcome_combo,
                 to_state_combo, to_outcome_combo,
                 free_from_states, free_from_outcomes_dict] = \
                    self.get_possible_combos_for_transition(transition, self.model, self.model)

                self.combo['internal'][transition_id]['from_state'] = from_state_combo
                self.combo['internal'][transition_id]['from_outcome'] = from_outcome_combo
                self.combo['internal'][transition_id]['to_state'] = to_state_combo
                self.combo['internal'][transition_id]['to_outcome'] = to_outcome_combo

                self.combo['free_from_states'] = free_from_states
                self.combo['free_from_outcomes_dict'] = free_from_outcomes_dict

            if not model.state.transitions:
                [x, y, z, v, free_from_states, free_from_outcomes_dict] = \
                    self.get_possible_combos_for_transition(None, self.model, self.model)
                self.combo['free_from_states'] = free_from_states
                self.combo['free_from_outcomes_dict'] = free_from_outcomes_dict
        # TODO check why the can happen should not be handed always the LibraryStateModel
        if not (self.model.state.is_root_state or self.model.state.is_root_state_of_library):
            # check for external combos
            for transition_id, transition in model.parent.state.transitions.items():
                if transition.from_state == model.state.state_id or transition.to_state == model.state.state_id:
                    self.combo['external'][transition_id] = {}

                    [from_state_combo, from_outcome_combo,
                     to_state_combo, to_outcome_combo,
                     free_from_states, free_from_outcomes_dict] = \
                        self.get_possible_combos_for_transition(transition, self.model.parent, self.model, True)

                    self.combo['external'][transition_id]['from_state'] = from_state_combo
                    self.combo['external'][transition_id]['from_outcome'] = from_outcome_combo
                    self.combo['external'][transition_id]['to_state'] = to_state_combo
                    self.combo['external'][transition_id]['to_outcome'] = to_outcome_combo

                    self.combo['free_ext_from_states'] = free_from_states
                    self.combo['free_ext_from_outcomes_dict'] = free_from_outcomes_dict

            if not model.parent.state.transitions:
                [x, y, z, v, free_from_states, free_from_outcomes_dict] = \
                    self.get_possible_combos_for_transition(None, self.model.parent, self.model, True)
                self.combo['free_ext_from_states'] = free_from_states
                self.combo['free_ext_from_outcomes_dict'] = free_from_outcomes_dict
849796
def load_model_data(self, path, model):
        
        if os.path.isdir(path):
            # try find a model data collection
            if os.path.isfile(os.path.join(path, '_all.yml')):
                self.load_model_data_collection(path, model)
            self.load_model_data_from_files(path, model)
            self.session.commit()
1197038
function modelItem(data, model) {
    var res = {};

    utils.defineProperties(res, {
        _isModelItem: { value: true },

        model: { value: model.value },

        update: { value: function(data, sync) {
            if (sync == null) sync = true;

            return update(res, model, data).then(function() {
                if (!sync) return;
                return res.save();
            });
        } },

        save: { value: function() {
            if (_.has(res, 'id')) {
                var props = serverProperties(res, model);
                return utils.socketPost(model.io, model.url + '/update/' + res.id, props.properties).then(function() {
                    return Promise.all(_.map(props.refresh, function(item) {
                        return item.refresh();
                    }));
                });
            }
            return create(res, model);
        } },

        refresh: { value: function() {
            if (!_.has(res, 'id')) return create(res, model);

            return utils.socketGet(model.io, model.url + '/' + res.id).then(function(data) {
                return update(res, model, data, { noRefresh: true });
            });
        } },

        delete: { value: function() {
            model._removeItem(res);
            return utils.socketDelete(model.io, model.url, { id: res.id });
        } },

        matches: { value: function(query) {
            return utils.socketGet(model.io, model.url, query).then(function(r) {
                for (var i = 0; i < r.length; i++) {
                    if (r[i].id === res.id) return true;
                }
                return false;
            });
        } },

        then: { value: function() {
            return res.ready.then.apply(res.ready, arguments);
        } },

        catch: { value: function() {
            return res.ready.catch.apply(res.ready, arguments);
        } }
    });

    res.ready = Promise.resolve();

    update(res, model, data || {});

    return res;
}
266350
def init_all_objects(self, data, target=None, single_result=True):
        
        if single_result:
            return self.init_target_object(target, data)
        return list(self.expand_models(target, data))
644020
def get_crud_menus(self):
        
        results = defaultdict(list)
        for object_type in settings.OBJECT_MENU:
            for model_data in settings.OBJECT_MENU[object_type]:
                if self.current.has_permission(model_data.get('wf', model_data['name'])):
                    self._add_crud(model_data, object_type, results)
        return results
1056049
def create_model_instance(self, data):
        
        return self.model(
            session_key=self._get_or_create_session_key(),
            session_data=self.encode(data),
            expire_date=self.get_expiry_date(),
        )
415220
def _add_results(self, results, trial_id):
        
        for result in results:
            self.logger.debug("Appending result: %s" % result)
            result["trial_id"] = trial_id
            result_record = ResultRecord.from_json(result)
            result_record.save()
402667
def get_data_for model
      model = apply_search_to(model)

      @data = model.limit(options[:per_page]).offset(start_item).order(options[:order])

      options[:total_count] = model.count
      options[:page_total] = (options[:total_count] / options[:per_page].to_f).ceil
    end
619982
def save_models(self, models_file):
        
        if self.model_parameters_iterations is None:
            raise ValueError("No iterations have been carried out yet and hence no iterations of the BO can be saved")

        iterations = np.array(range(1,self.model_parameters_iterations.shape[0]+1))[:,None]
        results = np.hstack((iterations,self.model_parameters_iterations))
        header = ['Iteration'] + self.model.get_model_parameters_names()

        data = [header] + results.tolist()
        self._write_csv(models_file, data)
104900
def crud_for_model(model, urlprefix=None):
    
    model_lower = model.__name__.lower()

    if urlprefix is None:
        urlprefix = ''
    urlprefix += model_lower + '/'

    urls = crud_urls(
        model,
        list_view=CRUDListView.as_view(model=model),
        create_view=CRUDCreateView.as_view(model=model),
        detail_view=CRUDDetailView.as_view(model=model),
        update_view=CRUDUpdateView.as_view(model=model),
        delete_view=CRUDDeleteView.as_view(model=model),
        url_prefix=urlprefix,
    )
    return urls
846573
public void displayModelPages(CmsModelInfo modelPageData) {

        m_modelPageTree.clear();
        m_modelPageTreeItems.clear();
        m_parentModelPageTreeItems.clear();

        if ((modelPageData.getParentModelPages() != null) && !modelPageData.getParentModelPages().isEmpty()) {
            m_parentModelPageRoot = CmsModelPageTreeItem.createRootItem(
                false,
                Messages.get().key(Messages.GUI_PARENT_MODEL_PAGE_TREE_ROOT_TITLE_0),
                "");

            for (CmsModelPageEntry parentModel : modelPageData.getParentModelPages()) {
                if (parentModel.isDisabled()) {
                    continue;
                }
                CmsModelPageTreeItem treeItem = new CmsModelPageTreeItem(parentModel, false, true);
                if (m_controller.isEditable()) {
                    CmsSitemapHoverbar.installOn(
                        m_controller,
                        treeItem,
                        parentModel.getStructureId(),
                        parentModel.getSitePath(),
                        parentModel.getSitePath() != null);
                }
                m_parentModelPageTreeItems.put(parentModel.getStructureId(), treeItem);
                m_parentModelPageRoot.addChild(treeItem);
                m_modelPageData.put(parentModel.getStructureId(), parentModel);
            }
            if (m_parentModelPageRoot.getChildren().getWidgetCount() > 0) {
                m_modelPageTree.add(m_parentModelPageRoot);
            } else {
                m_parentModelPageRoot = null;
            }
        } else {
            m_parentModelPageRoot = null;
        }
        m_modelPageRoot = CmsModelPageTreeItem.createRootItem(
            false,
            Messages.get().key(Messages.GUI_MODEL_PAGE_TREE_ROOT_TITLE_0),
            Messages.get().key(Messages.GUI_MODEL_PAGE_TREE_ROOT_SUBTITLE_0));
        if (m_controller.isEditable()) {
            CmsHoverbarCreateModelPageButton createButton = new CmsHoverbarCreateModelPageButton(false);
            CmsSitemapHoverbar hoverbar = CmsSitemapHoverbar.installOn(
                m_controller,
                m_modelPageRoot,
                Collections.<Widget> singleton(createButton));
            hoverbar.setAlwaysVisible();
            createButton.setHoverbar(hoverbar);
        }
        m_modelPageTree.add(m_modelPageRoot);
        for (CmsModelPageEntry entry : modelPageData.getModelPages()) {
            if (m_parentModelPageTreeItems.containsKey(entry.getStructureId())) {
                CmsModelPageTreeItem item = m_parentModelPageTreeItems.get(entry.getStructureId());
                item.setDisabled(entry.isDisabled());
            } else {
                m_modelPageData.put(entry.getStructureId(), entry);
                CmsModelPageTreeItem treeItem = new CmsModelPageTreeItem(entry, false, false);
                if (m_controller.isEditable()) {
                    CmsSitemapHoverbar.installOn(
                        m_controller,
                        treeItem,
                        entry.getStructureId(),
                        entry.getSitePath(),
                        entry.getSitePath() != null);
                }
                m_modelPageTreeItems.put(entry.getStructureId(), treeItem);
                m_modelPageRoot.addChild(treeItem);
            }
        }
        m_modelPageRoot.setOpen(true);
        m_modelGroupRoot = CmsModelPageTreeItem.createRootItem(
            true,
            Messages.get().key(Messages.GUI_MODEL_GROUP_PAGE_TREE_ROOT_TITLE_0),
            Messages.get().key(Messages.GUI_MODEL_GROUP_PAGE_TREE_ROOT_SUBTITLE_0));
        if (m_controller.isEditable()) {
            CmsHoverbarCreateModelPageButton createModelGroupButton = new CmsHoverbarCreateModelPageButton(true);
            CmsSitemapHoverbar modelGroupHoverbar = CmsSitemapHoverbar.installOn(
                m_controller,
                m_modelGroupRoot,
                Collections.<Widget> singleton(createModelGroupButton));
            modelGroupHoverbar.setAlwaysVisible();
            createModelGroupButton.setHoverbar(modelGroupHoverbar);
        }
        m_modelPageTree.add(m_modelGroupRoot);
        for (CmsModelPageEntry entry : modelPageData.getModelGroups()) {
            CmsModelPageTreeItem treeItem = new CmsModelPageTreeItem(entry, true, false);
            if (m_controller.isEditable()) {
                CmsSitemapHoverbar.installOn(
                    m_controller,
                    treeItem,
                    entry.getStructureId(),
                    entry.getSitePath(),
                    entry.getSitePath() != null);
            }
            m_modelPageTreeItems.put(entry.getStructureId(), treeItem);
            m_modelGroupRoot.addChild(treeItem);
        }
        m_modelGroupRoot.setOpen(true);
        m_modelPageTree.truncate(TM_SITEMAP, 920);
    }
1013972
def _update_view(self, p_data):
        
        view = self._viewdata_to_view(p_data)

        if self.column_mode == _APPEND_COLUMN or self.column_mode == _COPY_COLUMN:
            self._add_column(view)
        elif self.column_mode == _INSERT_COLUMN:
            self._add_column(view, self.columns.focus_position)
        elif self.column_mode == _EDIT_COLUMN:
            current_column = self.columns.focus

            current_column.title = p_data['title']
            current_column.view = view

        self._viewwidget_visible = False
        self._blur_commandline()
98193
def set(self, results):
        
        self.results = list()
        for row in results:
            self.append(row)
327874
def update(self, data=None, **kwargs):
        
        if data is None:
            data = {}
        data.update(kwargs)
        return self.model.write([self.id], data)
229907
def update_child_models(self, _, name, info):
        

        # Update is_start flag in child states if the start state has changed (eventually)
        if info.method_name in ['start_state_id', 'add_transition', 'remove_transition']:
            self.update_child_is_start()

        if info.method_name in ["add_transition", "remove_transition", "transitions"]:
            (model_list, data_list, model_name, model_class, model_key) = self._get_model_info("transition")
        elif info.method_name in ["add_data_flow", "remove_data_flow", "data_flows"]:
            (model_list, data_list, model_name, model_class, model_key) = self._get_model_info("data_flow")
        elif info.method_name in ["add_state", "remove_state", "states"]:
            (model_list, data_list, model_name, model_class, model_key) = self._get_model_info("state", info)
        elif info.method_name in ["add_scoped_variable", "remove_scoped_variable", "scoped_variables"]:
            (model_list, data_list, model_name, model_class, model_key) = self._get_model_info("scoped_variable")
        else:
            return

        if isinstance(info.result, Exception):
            # Do nothing if the observed function raised an exception
            pass
        elif "add" in info.method_name:
            self.add_missing_model(model_list, data_list, model_name, model_class, model_key)
        elif "remove" in info.method_name:
            destroy = info.kwargs.get('destroy', True)
            recursive = info.kwargs.get('recursive', True)
            self.remove_specific_model(model_list, info.result, model_key, recursive, destroy)
        elif info.method_name in ["transitions", "data_flows", "states", "scoped_variables"]:
            self.re_initiate_model_list(model_list, data_list, model_name, model_class, model_key)