#NEWLINE# def load( self , models , stream , model = None ) : #NEWLINE# #INDENT# if hasattr ( stream , 'read' ) : #NEWLINE# #INDENT# stream = stream . read ( ) #NEWLINE# #UNINDENT# data = json . loads ( stream , ** self . options ) #NEWLINE# for model_data in data : #NEWLINE# #INDENT# model = get_model_from_hash ( model_data [ 'hash' ] ) #NEWLINE# if model : #NEWLINE# #INDENT# model = self . on_load_model ( model , model_data ) #NEWLINE# if model : #NEWLINE# #INDENT# manager = models [ models ] #NEWLINE# LOGGER . info ( 'Loading model %s' , model . _meta ) #NEWLINE# session = manager . session ( ) #NEWLINE# with session . begin ( signal_commit = False ) as t : #NEWLINE# #INDENT# for item_data in model_data [ 'data' ] : #NEWLINE# #INDENT# t . add ( model . from_base64_data ( ** item_data ) ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# LOGGER . error ( 'Could not load model %s' , model_data . get ( 'model' ) ) #NEWLINE# #UNINDENT# #UNINDENT# self . on_finished_load ( )