Factory function that creates a value.

        :param value_id: id of the value, used to reference the value within this list.BaseException

        :param value_class: The class of the value that should be created with this function.
732
def add(self, value_id, name, value_class):
        
        item = value_class(
            name,
            value_id=self.controller.component_id + "." + value_id,
            is_input=self.is_input,
            index=self.count,
            spine = self.controller.spine
        )

        #if self._inject and self.controller:
        #    setattr(self.controller, value_id, item)
        #setattr(self, value_id, item)

        self.count += 1
        self._items[value_id] = item
        if self.is_input and self.controller:
            item.add_observer(self.controller)
        return item
515663
def add(class_, name, value, sep=';'):
		
		values = class_.get_values_list(name, sep)
		if value in values:
			return
		new_value = sep.join(values + [value])
		winreg.SetValueEx(
			class_.key, name, 0, winreg.REG_EXPAND_SZ, new_value)
		class_.notify()
966316
def instantiate_from_dict(self, values):
        

        name = values['ENGINE']
        options = values.get('OPTIONS', {})

        # Parse the name
        parts = name.split('.')
        module_name = '.'.join(parts[:-1])
        class_name = parts[-1]

        # Get the class
        try:
            module = import_module(module_name)
            cls = getattr(module, class_name)
        except (ValueError, AttributeError, TypeError, ImportError):
            raise ValueError('Cannot find class %s' % name)

        options = self.instantiate_objects(options)

        return cls(**options)
740397
def transform(self, value, **kwargs):
        
        if value is None:
            return None

        objid = id(value)
        if objid in self.context:
            return '<...>'
        self.context.add(objid)

        try:
            for serializer in self.serializers:
                try:
                    if serializer.can(value):
                        return serializer.serialize(value, **kwargs)
                except Exception as e:
                    logger.exception(e)
                    return text_type(type(value))

            # if all else fails, lets use the repr of the object
            try:
                return repr(value)
            except Exception as e:
                logger.exception(e)
                # It's common case that a model's __unicode__ definition
                # may try to query the database which if it was not
                # cleaned up correctly, would hit a transaction aborted
                # exception
                return text_type(type(value))
        finally:
            self.context.remove(objid)
921368
public <V> V getIdValue(T instance, Class<V> valueClass) {
        return getColumnValue(instance, idFieldName, valueClass);
    }
277173
function (factory, id) {

                    if (_.isFunction(factory)) {

                        var entityClassName = factory.prototype.constructor.name;

                        if (!entityClassName) {
                            throw new Error("No model class name defined");
                        }

                        var cachedItem;

                        // only get from cache if we got an id
                        if (id) {
                            cachedItem = this.getInstanceByCacheId(Context.generateCacheIdForEntity(entityClassName, id));
                        }

                        if (!cachedItem) {
                            var hash = {};
                            hash[factory.prototype.idField] = id;
                            // create new Entity
                            cachedItem = new factory(hash);

                            this.addEntity(cachedItem, true);
                        }

                        return cachedItem;

                    } else {
                        throw "Factory has to be a function";
                    }
                }
616499
def add_value(self, value, metadata=""):
        
        data = {
            'value': value,
            'metadata': metadata
        }

        return self.post('createValue', data)
632990
def create_or_update(ctx, model, xmlid, values):
    
    if isinstance(model, basestring):
        model = ctx.env[model]

    record = ctx.env.ref(xmlid, raise_if_not_found=False)
    if record:
        record.update(values)
    else:
        record = model.create(values)
        add_xmlid(ctx, record, xmlid)
    return record
785017
def instantiate_object_id_field(object_id_class_or_tuple=models.TextField):
    
    if isinstance(object_id_class_or_tuple, (list, tuple)):
        object_id_class, object_id_kwargs = object_id_class_or_tuple
    else:
        object_id_class = object_id_class_or_tuple
        object_id_kwargs = {}

    if not issubclass(object_id_class, models.fields.Field):
        raise TypeError('settings.%s must be a Django model field or (field, kwargs) tuple' % OBJECT_ID_TYPE_SETTING)
    if not isinstance(object_id_kwargs, dict):
        raise TypeError('settings.%s kwargs must be a dict' % OBJECT_ID_TYPE_SETTING)

    return object_id_class(db_index=True, **object_id_kwargs)
113787
def create(self, type_, **kwargs):
        
        obj = self.factory.create("ns0:%s" % type_)
        for key, value in kwargs.items():
            setattr(obj, key, value)
        return obj
388016
synchronized int id(Class<?> type) {
    Integer id = ids.get(type);
    if (id != null)
      return id;

    // If no ID was found for the given type, determine whether the type is an abstract type.
    Class<?> baseType = findBaseType(type, abstractFactories);
    if (baseType != null) {
      id = ids.get(baseType);
      if (id != null) {
        return id;
      }
    }
    return 0;
  }
840830
def value_call(method_name, *args, **kwargs):
    

    def value_call(value, context, **_params):
        method = getattr(value, method_name)
        return _call(method, args, kwargs)

    return value_call
610326
def ids(cls, values, itype=None):
        '''
        

        '''
        instance = cls(ids={'values': values})
        if itype is not None:
            instance['ids']['type'] = itype

        return instance
1121981
def template_id(self, value):
        
        if isinstance(value, TemplateId):
            self._template_id = value
        else:
            self._template_id = TemplateId(value)
593520
def unique_append(self, value):
    
    if value not in self:
        try:
            super(self.__class__, self).append(Uri(value))
        except AttributeError as err:
            if isinstance(value, MODULE.rdfclass.RdfClassBase):
                super(self.__class__, self).append(value)
            else:
                raise err
831159
def _createValueObjects(self, valueList, varList, mapTable, indexMap, contaminant, replaceParamFile):
        
        def assign_values_to_table(value_list, layer_id):
            for i, value in enumerate(value_list):
                value = vrp(value, replaceParamFile)
                # Create MTValue object and associate with MTIndex and MapTable
                mtValue = MTValue(variable=varList[i], value=float(value))
                mtValue.index = mtIndex
                mtValue.mapTable = mapTable
                mtValue.layer_id = layer_id

                # MTContaminant handler (associate MTValue with MTContaminant)
                if contaminant:
                    mtValue.contaminant = contaminant

        for row in valueList:
            # Create GSSHAPY MTIndex object and associate with IndexMap
            mtIndex = MTIndex(index=row['index'], description1=row['description1'], description2=row['description2'])
            mtIndex.indexMap = indexMap
            if len(np.shape(row['values'])) == 2:
                # this is for ids with multiple layers
                for layer_id, values in enumerate(row['values']):
                    assign_values_to_table(values, layer_id)
            else:
                assign_values_to_table(row['values'], 0)
1211589
def create(cls, id=None, **kwargs):
        
        what = cls(**kwargs)
        if id:
            setattr(what, cls.primaryKey, id)
        what.save()
        return what