#NEWLINE# def execute_session( self , session_data ) : #NEWLINE# #INDENT# 'Execute a session in redis.' #NEWLINE# pipe = self . client . pipeline ( ) #NEWLINE# for sm in session_data : #NEWLINE# #INDENT# meta = sm . meta #NEWLINE# if sm . structures : #NEWLINE# #INDENT# self . flush_structure ( sm , pipe ) #NEWLINE# #UNINDENT# delquery = None #NEWLINE# if ( sm . deletes is not None ) : #NEWLINE# #INDENT# delquery = sm . deletes . backend_query ( pipe = pipe ) #NEWLINE# #UNINDENT# self . accumulate_delete ( pipe , delquery ) #NEWLINE# if sm . dirty : #NEWLINE# #INDENT# meta_info = json . dumps ( self . meta ( meta ) ) #NEWLINE# lua_data = [ len ( sm . dirty ) ] #NEWLINE# processed = [ ] #NEWLINE# for instance in sm . dirty : #NEWLINE# #INDENT# state = instance . get_state ( ) #NEWLINE# if ( not meta . is_valid ( instance ) ) : #NEWLINE# #INDENT# raise FieldValueError ( json . dumps ( instance . _dbdata [ 'errors' ] ) ) #NEWLINE# #UNINDENT# score = MIN_FLOAT #NEWLINE# if meta . ordering : #NEWLINE# #INDENT# if meta . ordering . auto : #NEWLINE# #INDENT# score = meta . ordering . name . incrby #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# v = getattr ( instance , meta . ordering . name , None ) #NEWLINE# if ( v is not None ) : #NEWLINE# #INDENT# score = meta . ordering . field . scorefun ( v ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# data = instance . _dbdata [ 'cleaned_data' ] #NEWLINE# action = state . action #NEWLINE# prev_id = ( state . iid if state . persistent else '' ) #NEWLINE# id = ( instance . pkvalue ( ) or '' ) #NEWLINE# data = flat_mapping ( data ) #NEWLINE# lua_data . extend ( ( action , prev_id , id , score , len ( data ) ) ) #NEWLINE# lua_data . extend ( data ) #NEWLINE# processed . append ( state . iid ) #NEWLINE# #UNINDENT# self . odmrun ( pipe , 'commit' , meta , ( ) , meta_info , * lua_data , iids = processed ) #NEWLINE# #UNINDENT# #UNINDENT# return pipe . execute ( )