Set an instance of a thing.
173141
def set_instance(self, thing: type, value, overwrite=False):
        
        if thing in self.instances and not overwrite:
            raise DiayException('instance for %r already exists' % thing)
        self.instances[thing] = value
2139
def set_or_create(self, path, *args, **kwargs):
        """"""

        d = self.set(path, *args, **kwargs)

        @d.addErrback
        def _error(result):
            return self.create(path, *args, **kwargs)

        return d
1095931
def set(self, key, value):
        """"""
        self.store[key]=value
        return self.store
205135
def instance_of(klass, arg):
    """"""
    if not isinstance(arg, klass):
        raise com.IbisTypeError(
            'Given argument with type {} is not an instance of {}'.format(
                type(arg), klass
            )
        )
    return arg
474875
def create_instance(self, name, moduleName, settings):
        
        if name in self.insts:
            raise ValueError("There's already an instance named %s" %
                             name)
        if moduleName not in self.modules:
            raise ValueError("There's no module %s" % moduleName)
        md = self.modules[moduleName]
        deps = dict()
        for k, v in six.iteritems(md.deps):
            if k not in settings:
                settings[k] = self._get_or_create_a(v.type)
            if settings[k] is None:
                if not v.allow_null:
                    raise ValueError("`null' not allowed for %s" % k)
            elif settings[k] not in self.insts:
                raise ValueError("No such instance %s" % settings[k])
            else:
                settings[k] = self.insts[settings[k]].object
                deps[k] = settings[k]
        for k, v in six.iteritems(md.vsettings):
            if k not in settings:
                settings[k] = v.default
                if v.default is None:
                    self.l.warn('%s:%s not set' % (name, k))
        self.l.info('create_instance %-15s %s' % (name, md.implementedBy))
        cl = get_by_path(md.implementedBy)
        il = logging.getLogger(name)
        obj = cl(settings, il)
        self.register_instance(name, moduleName, obj, settings, deps)
        return obj
493568
def set_attr(self, key: str, value):
        """"""
        self.attr_setter(self, key, value)
391580
def on_set(self, key, value):
    """"""
    if self._on_set is not None:
      self._on_set(key, value)
559411
def set(self, instance, value, **kw):  # noqa
        
        ref = []
        # The value is an UID
        if api.is_uid(value):
            ref.append(value)

        # The value is a dictionary, get the UIDs.
        if u.is_dict(value):
            ref = ref.append(value.get("uid"))

        # The value is already an object
        if api.is_at_content(value):
            ref.append(value)

        # The value is a list
        if u.is_list(value):
            for item in value:
                # uid
                if api.is_uid(item):
                    ref.append(item)
                # dict (catalog query)
                elif u.is_dict(item):
                    # If there is UID of objects, just use it.
                    uid = item.get('uid', None)
                    if uid:
                        ref.append(uid)

        # Handle non multi valued fields
        if not self.multi_valued:
            if len(ref) > 1:
                raise ValueError("Multiple values given for single valued "
                                 "field {}".format(repr(self.field)))
            else:
                ref = ref[0]

        return self._set(instance, ref, **kw)
538580
private static function initInstance(): Instance
    {
        $instance = new Instance();
        if ($data = Config::get('registry')) {
            $instance->setFromArray($data);
        }
        return $instance;
    }
800291
def set_context(self, definition: Definition, explanation: str) -> None:
        """"""
        self.definition = definition
        self.explanation = explanation
113991
def set(self, value, parse=False):
        
        self.value = self.parse(value) if parse else value
780481
def _set(self, name, value):
        ""
        return self.widget(self.widget_element._set(name, value))
491499
def set( self, instance, value, **kwargs ):
        
        if not self._allow_write:
            raise AttributeError( "can't set Ref directly, allow_write is disabled" )
        target = instance
        for attr in self._path[:-1]:
            target = getattr( target, attr )
        setattr( target, self._path[-1], value )
        return
779935
def set_object(self, name: str, pobj: ParameterObject) -> None:
        """"""
        self.objects[zlib.crc32(name.encode())] = pobj
320972
def set(self, key, value, extend=False, **kwargs):
        """"""
        self.__setitem__(key, value, extend, **kwargs)
424836
function () {
      var a$ = this._instanceAttributes;
      for (var k in a$) {
        if (!this.hasAttribute(k)) {
          this.setAttribute(k, a$[k]);
        }
      }
    }
654759
def init_with_instance(self, instance):
        
        self._uid = api.get_uid(instance)
        self._brain = None
        self._catalog = self.get_catalog_for(instance)
        self._instance = instance