def _make_model_class(message_type, indexed_fields, **props):
analyzed = _analyze_indexed_fields(indexed_fields)<EOL>for field_name, sub_fields in analyzed.iteritems():<EOL><INDENT>if field_name in props:<EOL><INDENT>raise ValueError('<STR_LIT>' % field_name)<EOL><DEDENT>try:<EOL><INDENT>field = message_type.field_by_name(field_name)<EOL><DEDENT>except KeyError:<EOL><INDENT>raise ValueError('<STR_LIT>' %<EOL>(message_type.__name__, field_name))<EOL><DEDENT>if isinstance(field, messages.MessageField):<EOL><INDENT>if not sub_fields:<EOL><INDENT>raise ValueError(<EOL>'<STR_LIT>' % field_name)<EOL><DEDENT>sub_model_class = _make_model_class(field.type, sub_fields)<EOL>prop = model.StructuredProperty(sub_model_class, field_name,<EOL>repeated=field.repeated)<EOL><DEDENT>else:<EOL><INDENT>if sub_fields is not None:<EOL><INDENT>raise ValueError(<EOL>'<STR_LIT>' % field_name)<EOL><DEDENT>if isinstance(field, messages.EnumField):<EOL><INDENT>prop = EnumProperty(field.type, field_name, repeated=field.repeated)<EOL><DEDENT>elif isinstance(field, messages.BytesField):<EOL><INDENT>prop = model.BlobProperty(field_name,<EOL>repeated=field.repeated, indexed=True)<EOL><DEDENT>else:<EOL><INDENT>prop = model.GenericProperty(field_name, repeated=field.repeated)<EOL><DEDENT><DEDENT>props[field_name] = prop<EOL><DEDENT>return model.MetaModel('<STR_LIT>' % message_type.__name__,<EOL>(model.Model,), props)<EOL>
Construct a Model subclass corresponding to a Message subclass.

    Args:
      message_type: A Message subclass.
      indexed_fields: A list of dotted and undotted field names.
      **props: Additional properties with which to seed the class.

    Returns:
      A Model subclass whose properties correspond to those fields of
      message_type whose field name is listed in indexed_fields, plus
      the properties specified by the **props arguments.  For dotted
      field names, a StructuredProperty is generated using a Model
      subclass created by a recursive call.

    Raises:
      Whatever _analyze_indexed_fields() raises.
      ValueError if a field name conflicts with a name in **props.
      ValueError if a field name is not valid field of message_type.
      ValueError if an undotted field name designates a MessageField.