Returns the model with the given name, or creates one if it isn't existing until then and returns the new one.
15214
private ODocument getOrCreateModel(String model) {
        ODocument node = getModel(model);
        if (node == null) {
            node = graph.createVertex("Models");
            OrientModelGraphUtils.setIdFieldValue(node, model.toString());
            OrientModelGraphUtils.setActiveFieldValue(node, false);
            node.save();
        }
        return node;
    }
1357373
def _create_model(self, view_getter=None, source_getters=None,
                      model_factory=None, officer=None):
        

        if view_getter is not None:
            d = defer.succeed(view_getter)
            d.addCallback(self._retrieve_view)
            d.addCallback(self._check_view)
        else:
            # views are inherited
            d = defer.succeed(self.model.view)

        d.addCallback(self._retrieve_model, source_getters,
                      model_factory, officer)

        d.addErrback(self._filter_errors)
        return d
758148
def then_no_model_exists(context, model_name, key, value):
    
    model = apps.get_model(model_name)
    args = {
        key: value
    }
    obj = model.objects.filter(**args)
    assert len(obj) == 0
809434
function (name) {
    if (!this.instances[name]) {
      this.instances[name] = DevFixturesModel.create({name: name});
    }
    return this.instances[name];
  }
1173528
async def create_or_get(self, model_, **kwargs):
        
        try:
            return (await self.create(model_, **kwargs)), True
        except IntegrityErrors:
            query = []
            for field_name, value in kwargs.items():
                field = getattr(model_, field_name)
                if field.unique or field.primary_key:
                    query.append(field == value)
            return (await self.get(model_, *query)), False
862630
def model(self, model, create=True):
        ''''''
        manager = self.manager(model)
        sm = self._models.get(manager)
        if sm is None and create:
            sm = SessionModel(manager)
            self._models[manager] = sm
        return sm
373333
def get_or_create(self, **kwargs):
        

        model = self.get(**kwargs)

        is_created = False

        if model is None:
            is_created = True
            model = self._model_class()

            for key, value in list(kwargs.items()):
                setattr(model, key, value)

        return model, is_created
1100100
def get_name(model_id):
    
    name = _names.get(model_id)
    if name is None:
        name = 'id = %s (no name)' % str(model_id)
    return name
1119331
def build_model_name(cls, name='modelName', output_name='output'):
        
        obj = cls(name)
        obj.exporter = 'generate_model_name'
        obj.output_name = output_name
        return obj
1057686
def create(self, name=None, **kwargs):
        
        data = self._client.api.create_project({'name': name})
        return self.Meta.model(data, client=self._client, collection=self)
1316967
def new(self, name, *args, **kwargs):
        '''
        '''
        if name in self._instance_map:
            raise ValueError('Instance {0} is already initialized'
                             .format(name))

        instance = self._class_map[name](*args, **kwargs)
        self._instance_map[name] = instance
        return instance
668200
def get_existing_model(model_name):
    
    try:
        model_cls = engine.get_document_cls(model_name)
        log.debug('Model `{}` already exists. Using existing one'.format(
            model_name))
        return model_cls
    except ValueError:
        log.debug('Model `{}` does not exist'.format(model_name))
681084
def _get_model(self, appname, modelname):
        
        app = self._get_app(appname)
        models = app.get_models()
        model = None
        for mod in models:
            if mod.__name__ == modelname:
                model = mod
                return model
        msg = "Model " + modelname + " not found"
111031
def create_model(cls, name, field=None):
        
        if field:
            attrs = {'name': name, 'field': field}
        else:
            attrs = {'name': name, 'field': {'_id': ObjectId()}}

        return type(str(name), (cls, ), attrs)()
166515
function (connectionName, collectionName, obj, cb) {
        if (_.isObject(obj)) {
            try {
                var modelInstance = new this._model(obj);
                return cb(null, modelInstance);
            }
            catch (err) {
                return cb(err, null);
            }
        }
    }
116030
def new(self, *args, **kwargs):
        '''
'''
        return self.session().add(self.model(*args, **kwargs))
1017486
def _create(cls, model_class, *args, **kwargs):
        """"""
        if cls._meta.django_get_or_create:
            return cls._get_or_create(model_class, *args, **kwargs)

        manager = cls._get_manager(model_class)
        return manager.create(*args, **kwargs)