def set(self, column, value, useMethod=True, **context):
        """
        Sets the value for this record at the inputted column
        name.  If the columnName provided doesn't exist within
        the schema, then the ColumnNotFound error will be
        raised.

        :param      columnName      | <str>
                    value           | <variant>

        :return     <bool> changed
        """
        col = self.schema().column(column, raise_=False)

        if col is None:
            # allow setting of collections as well
            collector = self.schema().collector(column)
            if collector:
                my_context = self.context()

                for k, v in my_context.raw_values.items():
                    if k not in orb.Context.QueryFields:
                        context.setdefault(k, v)

                sub_context = orb.Context(**context)
                method = collector.settermethod()
                if method and useMethod:
                    return method(self, value, context=sub_context)
                else:
                    records = self.get(collector.name(), context=sub_context)
                    records.update(value,
                                   useMethod=useMethod,
                                   context=sub_context)

                    # remove any preloaded values from the collector
                    self.__preload.pop(collector.name(), None)

                    return records
            else:
                raise errors.ColumnNotFound(schema=self.schema(), column=column)

        elif col.testFlag(col.Flags.ReadOnly):
            raise errors.ColumnReadOnly(schema=self.schema(), column=column)

        context = self.context(**context)
        if useMethod:
            method = col.settermethod()
            if method:
                keywords = list(funcutil.extract_keywords(method))
                if 'locale' in keywords:
                    return method(self, value, locale=context.locale)
                else:
                    return method(self, value)

        if self.isRecord() and self.__delayed:
            self.__delayed = False
            self.read()

        with WriteLocker(self.__dataLock):
            orig, curr = self.__values.get(col.name(), (None, None))
            value = col.store(value, context)

            # update the context based on the locale value
            if col.testFlag(col.Flags.I18n) and isinstance(curr, dict) and isinstance(value, dict):
                new_value = curr.copy()
                new_value.update(value)
                value = new_value

            try:
                change = curr != value
            except TypeError:
                change = True

            if change:
                self.__values[col.name()] = (orig, value)

        # broadcast the change event
        if change:
            if col.testFlag(col.Flags.I18n) and context.locale != 'all':
                old_value = curr.get(context.locale) if isinstance(curr, dict) else curr
                new_value = value.get(context.locale) if isinstance(value, dict) else value
            else:
                old_value = curr
                new_value = value

            event = orb.events.ChangeEvent(record=self, column=col, old=old_value, value=new_value)
            if self.processEvent(event):
                self.onChange(event)
            if event.preventDefault:
                with WriteLocker(self.__dataLock):
                    orig, _ = self.__values.get(col.name(), (None, None))
                    self.__values[col.name()] = (orig, curr)
                return False
            else:
                return change
        else:
            return False
def set ( self , column , value , useMethod = True , ** context ) : col = self . schema ( ) . column ( column , raise_ = False ) if col is None : collector = self . schema ( ) . collector ( column ) if collector : my_context = self . context ( ) for k , v in my_context . raw_values . items ( ) : if k not in orb . Context . QueryFields : context . setdefault ( k , v ) sub_context = orb . Context ( ** context ) method = collector . settermethod ( ) if method and useMethod : return method ( self , value , context = sub_context ) else : records = self . get ( collector . name ( ) , context = sub_context ) records . update ( value , useMethod = useMethod , context = sub_context ) self . __preload . pop ( collector . name ( ) , None ) return records else : raise errors . ColumnNotFound ( schema = self . schema ( ) , column = column ) elif col . testFlag ( col . Flags . ReadOnly ) : raise errors . ColumnReadOnly ( schema = self . schema ( ) , column = column ) context = self . context ( ** context ) if useMethod : method = col . settermethod ( ) if method : keywords = list ( funcutil . extract_keywords ( method ) ) if 'locale' in keywords : return method ( self , value , locale = context . locale ) else : return method ( self , value ) if self . isRecord ( ) and self . __delayed : self . __delayed = False self . read ( ) with WriteLocker ( self . __dataLock ) : orig , curr = self . __values . get ( col . name ( ) , ( None , None ) ) value = col . store ( value , context ) if col . testFlag ( col . Flags . I18n ) and isinstance ( curr , dict ) and isinstance ( value , dict ) : new_value = curr . copy ( ) new_value . update ( value ) value = new_value try : change = curr != value except TypeError : change = True if change : self . __values [ col . name ( ) ] = ( orig , value ) if change : if col . testFlag ( col . Flags . I18n ) and context . locale != 'all' : old_value = curr . get ( context . locale ) if isinstance ( curr , dict ) else curr new_value = value . get ( context . locale ) if isinstance ( value , dict ) else value else : old_value = curr new_value = value event = orb . events . ChangeEvent ( record = self , column = col , old = old_value , value = new_value ) if self . processEvent ( event ) : self . onChange ( event ) if event . preventDefault : with WriteLocker ( self . __dataLock ) : orig , _ = self . __values . get ( col . name ( ) , ( None , None ) ) self . __values [ col . name ( ) ] = ( orig , curr ) return False else : return change else : return False
Sets the value for this record at the inputted column
        name.  If the columnName provided doesn't exist within
        the schema, then the ColumnNotFound error will be
        raised.

        :param      columnName      | <str>
                    value           | <variant>

        :return     <bool> changed