#NEWLINE# def _manage_space( self , size , target , tree_id ) : #NEWLINE# #INDENT# '\n        Manages spaces in the tree identified by ``tree_id`` by changing\n        the values of the left and right columns by ``size`` after the\n        given ``target`` point.\n        ' #NEWLINE# opts = self . model . _meta #NEWLINE# space_query = ( '\n        UPDATE %(table)s\n        SET %(left)s = CASE\n                WHEN %(left)s > %%s\n                    THEN %(left)s + %%s\n                ELSE %(left)s END,\n            %(right)s = CASE\n                WHEN %(right)s > %%s\n                    THEN %(right)s + %%s\n                ELSE %(right)s END\n        WHERE %(tree_id)s = %%s\n          AND (%(left)s > %%s OR %(right)s > %%s)' % { #NEWLINE# #INDENT# 'table' : qn ( opts . db_table ) , #NEWLINE# 'left' : qn ( opts . get_field ( self . left_attr ) . column ) , #NEWLINE# 'right' : qn ( opts . get_field ( self . right_attr ) . column ) , #NEWLINE# 'tree_id' : qn ( opts . get_field ( self . tree_id_attr ) . column ) , #NEWLINE# #UNINDENT# } ) #NEWLINE# cursor = connection . cursor ( ) #NEWLINE# cursor . execute ( space_query , [ target , size , target , size , tree_id , target , target ] )