See docs for `Model` abstract base class.
162815
def updateParams(self, newvalues, update_all=False):
        """"""
        assert all(map(lambda x: x in self.freeparams, newvalues.keys())),\
                "Invalid entry in newvalues: {0}\nfreeparams: {1}".format(
                ', '.join(newvalues.keys()), ', '.join(self.freeparams))
        changed = set([]) # contains string names of changed params
        for (name, value) in newvalues.items():
            _checkParam(name, value, self.PARAMLIMITS, self.PARAMTYPES)
            if isinstance(value, scipy.ndarray):
                if (value != getattr(self, name)).any():
                    changed.add(name)
                    setattr(self, name, value.copy())
            else:
                if value != getattr(self, name):
                    changed.add(name)
                    setattr(self, name, copy.copy(value))

        if update_all or changed:
            self._cached = {}

        # The order of the updating below is important.
        # If you change it, you may break either this class
        # **or** classes that inherit from it.
        # Note also that not all attributes need to be updated
        # for all possible parameter changes, but just doing it
        # this way is much simpler and adds negligible cost.
        if update_all or (changed and changed != set(['mu'])):
            self._update_Pxy()
            self._update_Pxy_diag()
            self._update_dPxy()
            self._update_B()
107657
def register_model(self, model_cls):
        """"""
        if not getattr(model_cls, '_database_'):
            raise ModelAttributeError('_database_ missing '
                                      'on %s!' % model_cls.__name__)
        if not getattr(model_cls, '_collection_'):
            raise ModelAttributeError('_collection_ missing '
                                      'on %s!' % model_cls.__name__)

        model_cls._mongo_client_ = self.client

        logging.info('Registering Model ' + model_cls.__name__)
        return model_cls
918883
def get_model(sender, model_name, model_inst, model_info, model_config):
    
    MC = get_mc()
    if MC:
        model = MC.get((MC.c.model_name==model_name) & (MC.c.uuid!=''))
        if model:
            cached_inst = __cache__.get(model_name)
            if not cached_inst or (cached_inst and cached_inst[1]!=model.uuid):
                model_inst = model.get_instance()
                M = orm.create_model(model_name, fields=eval(model_inst.fields or '[]'),
                                     indexes=eval(model_inst.indexes or '[]'),
                                     basemodel=model_inst.basemodel,
                                     __replace__=True)
                __cache__[model_name] = (M, model.uuid)

                #process extension model
                if model_inst.has_extension:
                    ext_model_name = model_name + '_extension'
                    fields = eval(model_inst.extension_fields or '[]')
                    fields.insert(0, {'name':'_parent', 'type':'OneToOne', 'reference_class':model_name, 'collection_name':'ext'})
                    ME = orm.create_model(ext_model_name, fields=fields,
                                          indexes=eval(model_inst.extension_indexes or '[]'),
                                          basemodel=model_inst.extension_model,
                                          __replace__=True)

            else:
                M = cached_inst[0]

            return M
913118
def load_model_from_package(name, **overrides):
    """"""
    cls = importlib.import_module(name)
    return cls.load(**overrides)
611794
def for_model(self, model, content_type=None):
        '''  '''
        content_type = content_type or ContentType.objects.get_for_model(model)
        kwargs = {
                    self.ct_field: content_type,
                    self.fk_field: model.pk
                 }
        objects = self.get_query_set().filter(**kwargs)
        return objects
123494
def resolve_model(self, model):
        '''
        
        '''
        if not model:
            raise ValueError('Unsupported model specifications')
        if isinstance(model, basestring):
            classname = model
        elif isinstance(model, dict) and 'class' in model:
            classname = model['class']
        else:
            raise ValueError('Unsupported model specifications')

        try:
            return get_document(classname)
        except self.NotRegistered:
            message = 'Model "{0}" does not exist'.format(classname)
            raise ValueError(message)
969753
def inheritanceTree(self):
        
        inherits = self.inherits()
        while inherits:
            ischema = orb.system.schema(inherits)
            if not ischema:
                raise orb.errors.ModelNotFound(schema=inherits)

            yield ischema
            inherits = ischema.inherits()
285137
def default_model():
    """"""
    project_root = get_project_root()
    models_dir = os.path.join(project_root, "models")
    curr_dir = os.getcwd()
    if os.path.commonprefix([models_dir, curr_dir]) == models_dir and \
       curr_dir != models_dir:
        latest_model = curr_dir
    else:
        latest_model = get_latest_folder(models_dir)
    return latest_model
1311947
def get_model_index_properties(instance, index):
    """"""
    mapping = get_index_mapping(index)
    doc_type = instance._meta.model_name.lower()
    return list(mapping["mappings"][doc_type]["properties"].keys())
1325467
def _find_model(self, constructor, table_name, constraints=None, *, columns=None, order_by=None):
    """"""
    data = self.find(table_name, constraints, columns=columns, order_by=order_by)
    return constructor(data) if data else None
792074
def _get_kind(cls):
    
    bases = cls._get_hierarchy()
    if not bases:
      # We have to jump through some hoops to call the superclass'
      # _get_kind() method.  First, this is called by the metaclass
      # before the PolyModel name is defined, so it can't use
      # super(PolyModel, cls)._get_kind().  Second, we can't just call
      # Model._get_kind() because that always returns 'Model'.  Hence
      # the 'im_func' hack.
      return model.Model._get_kind.im_func(cls)
    else:
      return bases[0]._class_name()
1316018
def _use_for_model(self, model):
        
        original_database = getattr(model, 'database', None)

        def get_models(model):
            """
            Return the model and all its submodels that are on the same database
            """
            model_database = getattr(model, 'database', None)
            if model_database == self:
                return []
            models = [model]
            for submodel in model.__subclasses__():
                if getattr(submodel, 'database', None) == model_database:
                    models += get_models(submodel)
            return models

        # put the model and all its matching submodels on the new database
        models = get_models(model)
        for _model in models:
            if not _model.abstract:
                self._add_model(_model)
                del original_database._models[_model._name]
            _model.database = self

        # return updated models
        return models
205281
def _find_models(self, constructor, table_name, constraints=None, *, columns=None,
                   order_by=None, limiting=None):
    """"""
    for record in self.find_all(table_name, constraints, columns=columns, order_by=order_by,
                                limiting=limiting):
      yield constructor(record)
1030365
def model_base(fulfil_client, cache_backend=None, cache_expire=10 * 60):
    
    return type(
        'BaseModel',
        (Model,),
        {
            'fulfil_client': fulfil_client,
            'cache_backend': cache_backend,
            'cache_expire': cache_expire,
            '__abstract__': True,
            '__modelregistry__': {},
        },
    )
133007
def doc(model):
    
    ins = inspect(model)

    return SaModelDoc(
        name=model.__name__,
        table=[t.name for t in ins.tables],
        doc=getdoc(ins.class_),
        columns=_model_columns(ins),
        primary=_model_primary(ins),
        foreign=_model_foreign(ins),
        unique=_model_unique(ins),
        relations=_model_relations(ins)
    )
982375
def get_by_model(self, model):
        """"""
        content_type = ContentType.objects.get_for_model(model)
        return self.filter(content_type=content_type)
449688
def models(self):
        """"""
        Model_ = self.app.config['PEEWEE_MODELS_CLASS']
        ignore = self.app.config['PEEWEE_MODELS_IGNORE']

        models = []
        if Model_ is not Model:
            try:
                mod = import_module(self.app.config['PEEWEE_MODELS_MODULE'])
                for model in dir(mod):
                    models = getattr(mod, model)
                    if not isinstance(model, pw.Model):
                        continue
                    models.append(models)
            except ImportError:
                return models
        elif isinstance(Model_, BaseSignalModel):
            models = BaseSignalModel.models

        return [m for m in models if m._meta.name not in ignore]