@@ -683,14 +683,30 @@ def _produce_instance(self, response):
683683 # Post-process the response
684684 new_instance ._local_update (response .json ())
685685
686- if new_instance .kind != new_instance ._meta_data ['required_json_kind' ] \
687- and new_instance .kind != "tm:transaction:commandsstate" :
688- error_message = "For instances of type '%r' the corresponding" \
689- " kind must be '%r' but creation returned JSON with kind: %r" \
690- % (new_instance .__class__ .__name__ ,
691- new_instance ._meta_data ['required_json_kind' ],
692- new_instance .kind )
693- raise KindTypeMismatch (error_message )
686+ # Allow for example files, which are KindTypeMismatches
687+ if hasattr (new_instance , 'selfLink' ):
688+ if new_instance .kind != new_instance ._meta_data [
689+ 'required_json_kind' ] \
690+ and new_instance .kind != "tm:transaction:commandsstate" \
691+ and 'example' not in new_instance .selfLink .split ('/' )[- 1 ]:
692+ error_message = "For instances of type '%r' the corresponding" \
693+ " kind must be '%r' but creation returned JSON with kind: %r" \
694+ % (new_instance .__class__ .__name__ ,
695+ new_instance ._meta_data [
696+ 'required_json_kind' ],
697+ new_instance .kind )
698+ raise KindTypeMismatch (error_message )
699+ else :
700+ if new_instance .kind != new_instance ._meta_data [
701+ 'required_json_kind' ] \
702+ and new_instance .kind != "tm:transaction:commandsstate" :
703+ error_message = "For instances of type '%r' the corresponding" \
704+ " kind must be '%r' but creation returned JSON with kind: %r" \
705+ % (new_instance .__class__ .__name__ ,
706+ new_instance ._meta_data [
707+ 'required_json_kind' ],
708+ new_instance .kind )
709+ raise KindTypeMismatch (error_message )
694710
695711 # Update the object to have the correct functional uri.
696712 new_instance ._activate_URI (new_instance .selfLink )
0 commit comments