#NEWLINE# def Deserializer( object_list , **options ) : #NEWLINE# #INDENT# "\n    Deserialize simple Python objects back into Django ORM instances.\n\n    It's expected that you pass the Python objects themselves (instead of a\n    stream or a string) to the constructor\n    " #NEWLINE# use_natural_keys = options . get ( 'use_natural_keys' , True ) #NEWLINE# for d in object_list : #NEWLINE# #INDENT# doc_cls = get_base_document ( d [ 'collection' ] ) #NEWLINE# data = d [ 'fields' ] #NEWLINE# if ( use_natural_keys and ( 'natural_key' in d ) ) : #NEWLINE# #INDENT# data [ '@natural_key' ] = d [ 'natural_key' ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( 'pk' in d ) : #NEWLINE# #INDENT# data [ doc_cls . _meta . pk . attname ] = doc_cls . _meta . pk . to_python ( d [ 'pk' ] ) #NEWLINE# #UNINDENT# #UNINDENT# if ( 'natural_key' in d ) : #NEWLINE# #INDENT# ( yield base . DeserializedObject ( doc_cls . to_python ( data ) , natural_key = d [ 'natural_key' ] ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# ( yield base . DeserializedObject ( doc_cls . to_python ( data ) ) )