def insert_many(self, it):
        """Inserts a collection of objects into the table."""
        unique_indexes = self._uniqueIndexes  # [ind for ind in self._indexes.values() if ind.is_unique]
        NO_SUCH_ATTR = object()
        new_objs = list(it)
        if unique_indexes:
            for ind in unique_indexes:
                ind_attr = ind.attr
                new_keys = dict((getattr(obj, ind_attr, NO_SUCH_ATTR), obj) for obj in new_objs)
                if not ind.accept_none and (None in new_keys or NO_SUCH_ATTR in new_keys):
                    raise KeyError("unique key cannot be None or blank for index %s" % ind_attr, 
                                    [ob for ob in new_objs if getattr(ob, ind_attr, NO_SUCH_ATTR) is None])
                if len(new_keys) < len(new_objs):
                    raise KeyError("given sequence contains duplicate keys for index %s" % ind_attr)
                for key in new_keys:
                    if key in ind:
                        obj = new_keys[key]
                        raise KeyError("duplicate unique key value '%s' for index %s" % (getattr(obj, ind_attr), ind_attr), 
                                       new_keys[key])
                    
        for obj in new_objs:
            self.obs.append(obj)
            for attr, ind in self._indexes.items():
                obval = getattr(obj, attr)
                ind[obval] = obj

        return self
def insert_many ( self , it ) : unique_indexes = self . _uniqueIndexes NO_SUCH_ATTR = object ( ) new_objs = list ( it ) if unique_indexes : for ind in unique_indexes : ind_attr = ind . attr new_keys = dict ( ( getattr ( obj , ind_attr , NO_SUCH_ATTR ) , obj ) for obj in new_objs ) if not ind . accept_none and ( None in new_keys or NO_SUCH_ATTR in new_keys ) : raise KeyError ( "unique key cannot be None or blank for index %s" % ind_attr , [ ob for ob in new_objs if getattr ( ob , ind_attr , NO_SUCH_ATTR ) is None ] ) if len ( new_keys ) < len ( new_objs ) : raise KeyError ( "given sequence contains duplicate keys for index %s" % ind_attr ) for key in new_keys : if key in ind : obj = new_keys [ key ] raise KeyError ( "duplicate unique key value '%s' for index %s" % ( getattr ( obj , ind_attr ) , ind_attr ) , new_keys [ key ] ) for obj in new_objs : self . obs . append ( obj ) for attr , ind in self . _indexes . items ( ) : obval = getattr ( obj , attr ) ind [ obval ] = obj return self
Inserts a collection of objects into the table.