def _index_document(index_list):
if isinstance(index_list, dict):<EOL><INDENT>raise TypeError("<STR_LIT>"<EOL>"<STR_LIT>"<EOL>"<STR_LIT>" % list(index_list.iteritems()))<EOL><DEDENT>elif not isinstance(index_list, list):<EOL><INDENT>raise TypeError("<STR_LIT>"<EOL>"<STR_LIT>" + repr(index_list))<EOL><DEDENT>if not len(index_list):<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>index = SON()<EOL>for (key, value) in index_list:<EOL><INDENT>if not isinstance(key, basestring):<EOL><INDENT>raise TypeError("<STR_LIT>")<EOL><DEDENT>if value not in [ASCENDING, DESCENDING, GEO2D]:<EOL><INDENT>raise TypeError("<STR_LIT>"<EOL>"<STR_LIT>")<EOL><DEDENT>index[key] = value<EOL><DEDENT>return index<EOL>
Helper to generate an index specifying document.

    Takes a list of (key, direction) pairs.