def assign_from_dict(self, variable):
        for column_name in self._automatic_assigned_column:
            if column_name in self._get_actual_column_names():
                column_type = self._get_actual_column_type(column_name)
                if column_name in variable and variable[column_name] != '':
                    value = variable[column_name]
                    if self.is_coltype_match(column_name, Upload): # upload
                        value = value.filename if hasattr(value,'filename') else None
                    elif isinstance(column_type, Date): # date
                        if value != '' and value is not None:
                            y,m,d = value.split('-')
                            y,m,d  = int(y), int(m), int(d)
                            value = datetime.date(y,m,d)
                        else:
                            value = None
                    elif isinstance(column_type, DateTime): # datetime
                        if value != '' and value is not None:
                            date_part, time_part = value.split(' ')
                            y,m,d = date_part.split('-')
                            h,i,s = time_part.split(':')
                            y,m,d = int(y), int(m), int(d)
                            h,i,s = int(h), int(i), int(s)
                            value = datetime.datetime(y,m,d,h,i,s)
                        else:
                            value = None
                    elif isinstance(column_type, Boolean):
                        if value == '0':
                            value = False
                        else:
                            value = True
                    if value is not None:
                        value = decode_string(value)
                        setattr(self, column_name, value)
            elif column_name in self._get_relation_names():
                relation_metadata = self._get_relation_metadata(column_name)
                # one to many
                if relation_metadata.uselist:
                    ref_class = self._get_relation_class(column_name)

                    ref_obj = ref_class()
                    # determine if the model is ordered
                    is_ordered = isinstance(ref_obj, Ordered_DB_Model)
                    # custom_label and shown column
                    custom_label = self.__detail_column_label__[column_name]\
                        if column_name in self.__detail_column_label__ else {}
                    shown_column = self._get_detail_column_list(column_name)

                    # if only one column to be shown and it is a relationship
                    if len(shown_column) == 1 and shown_column[0] in ref_obj._get_relation_names():
                        list_val       = [] # value from variable
                        list_lookup    = [] # lookup (from list_val)
                        list_old       = [] # old lookup value (from database)
                        relation_value = [] # old relation value (from database)
                        lookup_class   = ref_obj._get_relation_class(shown_column[0])
                        # get list value
                        variable_key = column_name + '[]'
                        if hasattr(variable, 'getall') and variable_key in variable:                            
                            list_val = variable.getall(variable_key)
                        # get list_lookup based on list_val                        
                        for val in list_val:
                            list_lookup.append(lookup_class.find(val))
                        # get old relation_value
                        relation_value = self._get_relation_value(column_name)
                        # if old_val not in list_lookup, delete it
                        for child in relation_value:
                            old_val = getattr(child, shown_column[0])
                            list_old.append(old_val)
                            # delete
                            if old_val not in list_lookup:
                                if getattr(self, column_name) in child:
                                    getattr(self, column_name).remove(child)
                                child.trash()
                            # edit if is_ordered
                            elif is_ordered:
                                for index, val in enumerate(list_lookup):
                                    if old_val == val:
                                        child._index = index + 1
                                        break
                        # if list_lookup not in old_val.shown_column[0], add it, set index if is_ordered
                        for index, val in enumerate(list_lookup):
                            if val not in list_old:
                                param = {shown_column[0] : val}
                                if is_ordered:
                                    param['_index'] = index + 1
                                new_record = ref_class(**param)
                                getattr(self, column_name).append(new_record)
                    # else, it must be tabular  
                    else:
                        # one to many
                        old_id_list             = [] # old id from database        
                        deleted_list            = [] # deleted id from variable (form)
                        relation_variable_list  = [] # from variable (form)
                        index_list              = [] # indexes from variable (form)
                        record_count            = 0  # total record count (from variable)
                        # by default bottle request doesn't automatically accept 
                        # POST with [] name
                        for variable_key in variable:
                            if hasattr(variable, 'getall') and variable_key[0:len(column_name)] == column_name and variable_key[-2:] == '[]':
                                # get list value
                                list_val = variable.getall(variable_key)                            
                                # make list of dictionary (as much as needed)
                                while record_count < len(list_val):
                                    relation_variable_list.append({})
                                    record_count +=1
                                new_variable_key = variable_key[len(column_name)+1:-2]
                                for i in xrange(record_count):
                                    relation_variable_list[i][new_variable_key] = list_val[i]
                        # special variables
                        if hasattr(variable, 'getall'):
                            old_id_list = variable.getall('_' + column_name + '_id[]')
                            deleted_list = variable.getall('_' + column_name + '_delete[]')
                            if issubclass(ref_class, Ordered_DB_Model):
                                index_list = variable.getall('_' + column_name + '_index[]')
                        # get relation
                        relation_value = self._get_relation_value(column_name)
                        for i in xrange(record_count):
                            old_id = old_id_list[i]
                            deleted = deleted_list[i] == "1"
                            relation_variable = relation_variable_list[i]
                            if is_ordered:
                                index = index_list[i]
                            ref_obj = None
                            for child in relation_value:
                                if isinstance(child, DB_Model):
                                    if child.id == old_id:
                                        ref_obj = child
                                        ref_obj.assign_from_dict(relation_variable)
                                        break
                            if ref_obj is None:
                                ref_obj = ref_class()
                                ref_obj.assign_from_dict(relation_variable)
                                getattr(self, column_name).append(ref_obj)
                            if is_ordered:
                                ref_obj._index = index
                            if deleted:
                                if ref_obj in getattr(self, column_name):
                                    getattr(self, column_name).remove(ref_obj)
                                ref_obj.trash()
                else:
                    # many to one
                    if column_name in variable and variable[column_name] != '':
                        value = variable[column_name]
                        if value != '':
                            ref_class = self._get_relation_class(column_name)
                            value = ref_class.find(value)
                        setattr(self, column_name, value)
dataset/ETHPy150Open goFrendiAsgard/kokoropy/kokoropy/model.py/DB_Model.assign_from_dict/swapped operands of `in`